<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
  <meta name="theme-color" content="#222">
  <meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/safari-pinned-tab.svg" color="#222">
  <link rel="stylesheet" href="/css/main.css">
  <link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>
  <script id="hexo-configurations">
    var NexT = window.NexT ||
    {};
    var CONFIG = {
      "hostname": "cuiqingcai.com",
      "root": "/",
      "scheme": "Pisces",
      "version": "7.8.0",
      "exturl": false,
      "sidebar":
      {
        "position": "right",
        "width": 360,
        "display": "post",
        "padding": 18,
        "offset": 12,
        "onmobile": false,
        "widgets": [
          {
            "type": "image",
            "name": "阿布云",
            "enable": false,
            "url": "https://www.abuyun.com/http-proxy/introduce.html",
            "src": "https://qiniu.cuiqingcai.com/88au8.jpg",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "天验",
            "enable": true,
            "url": "https://tutorial.lengyue.video/?coupon=12ef4b1a-a3db-11ea-bb37-0242ac130002_cqx_850",
            "src": "https://qiniu.cuiqingcai.com/bco2a.png",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "华为云",
            "enable": false,
            "url": "https://activity.huaweicloud.com/2020_618_promotion/index.html?bpName=5f9f98a29e2c40b780c1793086f29fe2&bindType=1&salesID=wangyubei",
            "src": "https://qiniu.cuiqingcai.com/y42ik.jpg",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "张小鸡",
            "enable": false,
            "url": "http://www.zxiaoji.com/",
            "src": "https://qiniu.cuiqingcai.com/fm72f.png",
            "width": "100%"
      },
          {
            "type": "image",
            "name": "Luminati",
            "src": "https://qiniu.cuiqingcai.com/ikkq9.jpg",
            "url": "https://luminati-china.io/?affiliate=ref_5fbbaaa9647883f5c6f77095",
            "width": "100%",
            "enable": false
      },
          {
            "type": "image",
            "name": "IPIDEA",
            "url": "http://www.ipidea.net/?utm-source=cqc&utm-keyword=?cqc",
            "src": "https://qiniu.cuiqingcai.com/0ywun.png",
            "width": "100%",
            "enable": true
      },
          {
            "type": "tags",
            "name": "标签云",
            "enable": true
      },
          {
            "type": "categories",
            "name": "分类",
            "enable": true
      },
          {
            "type": "friends",
            "name": "友情链接",
            "enable": true
      },
          {
            "type": "hot",
            "name": "猜你喜欢",
            "enable": true
      }]
      },
      "copycode":
      {
        "enable": true,
        "show_result": true,
        "style": "mac"
      },
      "back2top":
      {
        "enable": true,
        "sidebar": false,
        "scrollpercent": true
      },
      "bookmark":
      {
        "enable": false,
        "color": "#222",
        "save": "auto"
      },
      "fancybox": false,
      "mediumzoom": false,
      "lazyload": false,
      "pangu": true,
      "comments":
      {
        "style": "tabs",
        "active": "gitalk",
        "storage": true,
        "lazyload": false,
        "nav": null,
        "activeClass": "gitalk"
      },
      "algolia":
      {
        "hits":
        {
          "per_page": 10
        },
        "labels":
        {
          "input_placeholder": "Search for Posts",
          "hits_empty": "We didn't find any results for the search: ${query}",
          "hits_stats": "${hits} results found in ${time} ms"
        }
      },
      "localsearch":
      {
        "enable": true,
        "trigger": "auto",
        "top_n_per_article": 10,
        "unescape": false,
        "preload": false
      },
      "motion":
      {
        "enable": false,
        "async": false,
        "transition":
        {
          "post_block": "bounceDownIn",
          "post_header": "slideDownIn",
          "post_body": "slideDownIn",
          "coll_header": "slideLeftIn",
          "sidebar": "slideUpIn"
        }
      },
      "path": "search.xml"
    };

  </script>
  <meta name="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
  <meta property="og:type" content="website">
  <meta property="og:title" content="静觅">
  <meta property="og:url" content="https://cuiqingcai.com/page/19/index.html">
  <meta property="og:site_name" content="静觅">
  <meta property="og:description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
  <meta property="og:locale" content="zh_CN">
  <meta property="article:author" content="崔庆才">
  <meta property="article:tag" content="崔庆才">
  <meta property="article:tag" content="静觅">
  <meta property="article:tag" content="PHP">
  <meta property="article:tag" content="Java">
  <meta property="article:tag" content="Python">
  <meta property="article:tag" content="Spider">
  <meta property="article:tag" content="爬虫">
  <meta property="article:tag" content="Web">
  <meta property="article:tag" content="Kubernetes">
  <meta property="article:tag" content="深度学习">
  <meta property="article:tag" content="机器学习">
  <meta property="article:tag" content="数据分析">
  <meta property="article:tag" content="网络">
  <meta property="article:tag" content="IT">
  <meta property="article:tag" content="技术">
  <meta property="article:tag" content="博客">
  <meta name="twitter:card" content="summary">
  <link rel="canonical" href="https://cuiqingcai.com/page/19/">
  <script id="page-configurations">
    // https://hexo.io/docs/variables.html
    CONFIG.page = {
      sidebar: "",
      isHome: true,
      isPost: false,
      lang: 'zh-CN'
    };

  </script>
  <title>静觅丨崔庆才的个人站点</title>
  <meta name="google-site-verification" content="p_bIcnvirkFzG2dYKuNDivKD8-STet5W7D-01woA2fc" />
  <noscript>
    <style>
      .use-motion .brand,
      .use-motion .menu-item,
      .sidebar-inner,
      .use-motion .post-block,
      .use-motion .pagination,
      .use-motion .comments,
      .use-motion .post-header,
      .use-motion .post-body,
      .use-motion .collection-header
      {
        opacity: initial;
      }

      .use-motion .site-title,
      .use-motion .site-subtitle
      {
        opacity: initial;
        top: initial;
      }

      .use-motion .logo-line-before i
      {
        left: initial;
      }

      .use-motion .logo-line-after i
      {
        right: initial;
      }

    </style>
  </noscript>
  <link rel="alternate" href="/atom.xml" title="静觅" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container">
    <div class="headband"></div>
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner">
        <div class="site-brand-container">
          <div class="site-nav-toggle">
            <div class="toggle" aria-label="切换导航栏">
              <span class="toggle-line toggle-line-first"></span>
              <span class="toggle-line toggle-line-middle"></span>
              <span class="toggle-line toggle-line-last"></span>
            </div>
          </div>
          <div class="site-meta">
            <a href="/" class="brand" rel="start">
              <span class="logo-line-before"><i></i></span>
              <h1 class="site-title">静觅 <span class="site-subtitle"> 崔庆才的个人站点 </span>
              </h1>
              <span class="logo-line-after"><i></i></span>
            </a>
          </div>
          <div class="site-nav-right">
            <div class="toggle popup-trigger">
              <i class="fa fa-search fa-fw fa-lg"></i>
            </div>
          </div>
        </div>
        <nav class="site-nav">
          <ul id="menu" class="main-menu menu">
            <li class="menu-item menu-item-home">
              <a href="/" rel="section">首页</a>
            </li>
            <li class="menu-item menu-item-archives">
              <a href="/archives/" rel="section">文章列表</a>
            </li>
            <li class="menu-item menu-item-tags">
              <a href="/tags/" rel="section">文章标签</a>
            </li>
            <li class="menu-item menu-item-categories">
              <a href="/categories/" rel="section">文章分类</a>
            </li>
            <li class="menu-item menu-item-about">
              <a href="/about/" rel="section">关于博主</a>
            </li>
            <li class="menu-item menu-item-message">
              <a href="/message/" rel="section">给我留言</a>
            </li>
            <li class="menu-item menu-item-search">
              <a role="button" class="popup-trigger">搜索 </a>
            </li>
          </ul>
        </nav>
        <div class="search-pop-overlay">
          <div class="popup search-popup">
            <div class="search-header">
              <span class="search-icon">
                <i class="fa fa-search"></i>
              </span>
              <div class="search-input-container">
                <input autocomplete="off" autocapitalize="off" placeholder="搜索..." spellcheck="false" type="search" class="search-input">
              </div>
              <span class="popup-btn-close">
                <i class="fa fa-times-circle"></i>
              </span>
            </div>
            <div id="search-result">
              <div id="no-result">
                <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
              </div>
            </div>
          </div>
        </div>
      </div>
    </header>
    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
      <span>0%</span>
    </div>
    <div class="reading-progress-bar"></div>
    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div class="content index posts-expand">
            <div class="carousel">
              <div id="wowslider-container">
                <div class="ws_images">
                  <ul>
                    <li><a target="_blank" href="https://cuiqingcai.com/5052.html"><img title="Python3网络爬虫开发实战教程" src="https://qiniu.cuiqingcai.com/ipy96.jpg" /></a></li>
                    <li><a target="_blank" href="https://t.lagou.com/fRCBRsRCSN6FA"><img title="52讲轻松搞定网络爬虫" src="https://qiniu.cuiqingcai.com/fqq5e.png" /></a></li>
                    <li><a target="_blank" href="https://brightdata.grsm.io/cuiqingcai"><img title="亮网络解锁器" src="https://qiniu.cuiqingcai.com/6qnb7.png" /></a></li>
                    <li><a target="_blank" href="https://cuiqingcai.com/4320.html"><img title="Python3网络爬虫开发视频教程" src="https://qiniu.cuiqingcai.com/bjrny.jpg" /></a></li>
                    <li><a target="_blank" href="https://cuiqingcai.com/5094.html"><img title="爬虫代理哪家强？十大付费代理详细对比评测出炉！" src="https://qiniu.cuiqingcai.com/nifs6.jpg" /></a></li>
                  </ul>
                </div>
                <div class="ws_thumbs">
                  <div>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/ipy96.jpg" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/fqq5e.png" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/6qnb7.png" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/bjrny.jpg" /></a>
                    <a target="_blank" href="#"><img src="https://qiniu.cuiqingcai.com/nifs6.jpg" /></a>
                  </div>
                </div>
                <div class="ws_shadow"></div>
              </div>
            </div>
            <link rel="stylesheet" href="/lib/wowslide/slide.css">
            <script src="/lib/wowslide/jquery.min.js"></script>
            <script src="/lib/wowslide/slider.js"></script>
            <script>
              jQuery("#wowslider-container").wowSlider(
              {
                effect: "cube",
                prev: "",
                next: "",
                duration: 20 * 100,
                delay: 20 * 100,
                width: 716,
                height: 297,
                autoPlay: true,
                playPause: true,
                stopOnHover: false,
                loop: false,
                bullets: 0,
                caption: true,
                captionEffect: "slide",
                controls: true,
                onBeforeStep: 0,
                images: 0
              });

            </script>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5428.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5428.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.8.3-Scrapy-Splash的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapy-Splash是一个Scrapy中支持JavaScript渲染的工具，本节来介绍它的安装方式。</p>
                  <p>Scrapy-Splash的安装分为两部分。一个是Splash服务的安装，具体是通过Docker，安装之后，会启动一个Splash服务，我们可以通过它的接口来实现JavaScript页面的加载。另外一个是Scrapy-Splash的Python库的安装，安装之后即可在Scrapy中使用Splash服务。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/scrapy-plugins/scrapy-splash" target="_blank" rel="noopener">https://github.com/scrapy-plugins/scrapy-splash</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/scrapy-splash" target="_blank" rel="noopener">https://pypi.python.org/pypi/scrapy-splash</a></li>
                    <li>使用说明：<a href="https://github.com/scrapy-plugins/scrapy-splash#configuration" target="_blank" rel="noopener">https://github.com/scrapy-plugins/scrapy-splash#configuration</a></li>
                    <li>Splash官方文档：<a href="http://splash.readthedocs.io/" target="_blank" rel="noopener">http://splash.readthedocs.io</a></li>
                  </ul>
                  <h2 id="2-安装Splash"><a href="#2-安装Splash" class="headerlink" title="2. 安装Splash"></a>2. 安装Splash</h2>
                  <p>Scrapy-Splash会使用Splash的HTTP API进行页面渲染，所以我们需要安装Splash来提供渲染服务。这里通过Docker安装，在这之前请确保已经正确安装好了Docker。</p>
                  <p>安装命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run -p <span class="number">8050</span>:<span class="number">8050</span> scrapinghub/splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>安装完成之后，会有类似的输出结果：</p>
                  <figure class="highlight yaml">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28+0000</span> <span class="string">[-]</span> <span class="string">Log</span> <span class="string">opened.</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.447291</span> <span class="string">[-]</span> <span class="attr">Splash version:</span> <span class="number">3.0</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.452698</span> <span class="string">[-]</span> <span class="string">Qt</span> <span class="number">5.9</span><span class="number">.1</span><span class="string">,</span> <span class="string">PyQt</span> <span class="number">5.9</span><span class="string">,</span> <span class="string">WebKit</span> <span class="number">602.1</span><span class="string">,</span> <span class="string">sip</span> <span class="number">4.19</span><span class="number">.3</span><span class="string">,</span> <span class="string">Twisted</span> <span class="number">16.1</span><span class="number">.1</span><span class="string">,</span> <span class="string">Lua</span> <span class="number">5.2</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.453120</span> <span class="string">[-]</span> <span class="string">Python</span> <span class="number">3.5</span><span class="number">.2</span> <span class="string">(default,</span> <span class="string">Nov</span> <span class="number">17</span> <span class="number">2016</span><span class="string">,</span> <span class="number">17</span><span class="string">:05:23)</span> <span class="string">[GCC</span> <span class="number">5.4</span><span class="number">.0</span> <span class="number">20160609</span><span class="string">]</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.453676</span> <span class="string">[-]</span> <span class="attr">Open files limit:</span> <span class="number">1048576</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.454258</span> <span class="string">[-]</span> <span class="string">Can't</span> <span class="string">bump</span> <span class="string">open</span> <span class="string">files</span> <span class="string">limit</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:28.571306</span> <span class="string">[-]</span> <span class="attr">Xvfb is started:</span> <span class="string">['Xvfb',</span> <span class="string">':1599197258'</span><span class="string">,</span> <span class="string">'-screen'</span><span class="string">,</span> <span class="string">'0'</span><span class="string">,</span> <span class="string">'1024x768x24'</span><span class="string">,</span> <span class="string">'-nolisten'</span><span class="string">,</span> <span class="string">'tcp'</span><span class="string">]</span></span><br><span class="line"><span class="attr">QStandardPaths:</span> <span class="string">XDG_RUNTIME_DIR</span> <span class="string">not</span> <span class="string">set,</span> <span class="string">defaulting</span> <span class="string">to</span> <span class="string">'/tmp/runtime-root'</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.041973</span> <span class="string">[-]</span> <span class="string">proxy</span> <span class="string">profiles</span> <span class="string">support</span> <span class="string">is</span> <span class="string">enabled,</span> <span class="attr">proxy profiles path:</span> <span class="string">/etc/splash/proxy-profiles</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.315445</span> <span class="string">[-]</span> <span class="string">verbosity=1</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.315629</span> <span class="string">[-]</span> <span class="string">slots=50</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.315712</span> <span class="string">[-]</span> <span class="string">argument_cache_max_entries=500</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.316564</span> <span class="string">[-]</span> <span class="attr">Web UI:</span> <span class="string">enabled,</span> <span class="attr">Lua:</span> <span class="string">enabled</span> <span class="string">(sandbox:</span> <span class="string">enabled)</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.317614</span> <span class="string">[-]</span> <span class="string">Site</span> <span class="string">starting</span> <span class="string">on</span> <span class="number">8050</span></span><br><span class="line"><span class="number">2017</span><span class="number">-07</span><span class="number">-03</span> <span class="number">08</span><span class="string">:53:29.317801</span> <span class="string">[-]</span> <span class="string">Starting</span> <span class="string">factory</span> <span class="string">&lt;twisted.web.server.Site</span> <span class="string">object</span> <span class="string">at</span> <span class="number">0x7ffaa4a98cf8</span><span class="string">&gt;</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就证明Splash已经在8050端口上运行了。这时我们打开<a href="http://localhost:8050/" target="_blank" rel="noopener">http://localhost:8050</a>，即可看到Splash的主页，如图1-80所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-81.png" alt="">图1-80 运行页面</p>
                  <p>当然，Splash也可以直接安装在远程服务器上。我们在服务器上以守护态运行Splash即可，命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run -d -p <span class="number">8050</span>:<span class="number">8050</span> scrapinghub/splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这里多了<code>\-d</code>参数，它代表将Docker容器以守护态运行，这样在中断远程服务器连接后，不会终止Splash服务的运行。</p>
                  <h2 id="3-Scrapy-Splash的安装"><a href="#3-Scrapy-Splash的安装" class="headerlink" title="3. Scrapy-Splash的安装"></a>3. Scrapy-Splash的安装</h2>
                  <p>成功安装Splash之后，接下来再来安装其Python库，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> scrapy-splash</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令运行完毕后，就会成功安装好此库，后面会详细介绍它的用法。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 23:30:00" itemprop="dateCreated datePublished" datetime="2018-01-25T23:30:00+08:00">2018-01-25</time>
                </span>
                <span id="/5428.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.8.3-Scrapy-Splash的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>1.9k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5421.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5421.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.8.2-Scrapy的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Scrapy是一个十分强大的爬虫框架，依赖的库比较多，至少需要依赖的库有Twisted 14.0、lxml 3.4和pyOpenSSL 0.14。在不同的平台环境下，它所依赖的库也各不相同，所以在安装之前，最好确保把一些基本库安装好。本节就来介绍Scrapy在不同平台的安装方法。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://scrapy.org/" target="_blank" rel="noopener">https://scrapy.org</a></li>
                    <li>官方文档：<a href="https://docs.scrapy.org/" target="_blank" rel="noopener">https://docs.scrapy.org</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/Scrapy" target="_blank" rel="noopener">https://pypi.python.org/pypi/Scrapy</a></li>
                    <li>GitHub：<a href="https://github.com/scrapy/scrapy" target="_blank" rel="noopener">https://github.com/scrapy/scrapy</a></li>
                    <li>中文文档：<a href="http://scrapy-chs.readthedocs.io/" target="_blank" rel="noopener">http://scrapy-chs.readthedocs.io</a></li>
                  </ul>
                  <h2 id="2-Anaconda安装"><a href="#2-Anaconda安装" class="headerlink" title="2. Anaconda安装"></a>2. Anaconda安装</h2>
                  <p>这是一种比较简单的安装Scrapy的方法（尤其是对于Windows来说），如果你的Python是使用Anaconda安装的，或者还没有安装Python的话，可以使用此方法安装，这种方法简单、省力。当然，如果你的Python不是通过Anaconda安装的，可以继续看后面的内容。</p>
                  <p>关于Anaconda的安装方式，可以查看1.1节，在此不再赘述。</p>
                  <p>如果已经安装好了Anaconda，那么可以通过<code>conda</code>命令安装Scrapy，具体如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">conda <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="3-Windows下的安装"><a href="#3-Windows下的安装" class="headerlink" title="3. Windows下的安装"></a>3. Windows下的安装</h2>
                  <p>如果你的Python不是使用Anaconda安装的，可以参考如下方式来一步步安装Scrapy。</p>
                  <h3 id="安装lxml"><a href="#安装lxml" class="headerlink" title="安装lxml"></a>安装lxml</h3>
                  <p>lxml的安装过程请参见1.3.1节，在此不再赘述，此库非常重要，请一定要安装成功。</p>
                  <h3 id="安装pyOpenSSL"><a href="#安装pyOpenSSL" class="headerlink" title="安装pyOpenSSL"></a>安装pyOpenSSL</h3>
                  <p>在官方网站下载wheel文件（详见<a href="https://pypi.python.org/pypi/pyOpenSSL#downloads" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyOpenSSL#downloads</a>）即可，如图1-76所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-77.jpg" alt="">图1-76 下载页面</p>
                  <p>下载后利用pip安装即可：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">pyOpenSSL-17</span><span class="selector-class">.2</span><span class="selector-class">.0-py2</span><span class="selector-class">.py3-none-any</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="安装Twisted"><a href="#安装Twisted" class="headerlink" title="安装Twisted"></a>安装Twisted</h3>
                  <p>到<a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted" target="_blank" rel="noopener">http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted</a>下载wheel文件，利用pip安装即可。</p>
                  <p>比如，对于Python 3.6版本、Windows 64位系统，则当前最新版本为Twisted‑17.5.0‑cp36‑cp36m‑win_amd64.whl，直接下载即可，如图1-77所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-78.jpg" alt="">图1-77 下载页面</p>
                  <p>然后通过pip安装：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">Twisted</span>‑17<span class="selector-class">.5</span><span class="selector-class">.0</span>‑<span class="selector-tag">cp36</span>‑<span class="selector-tag">cp36m</span>‑<span class="selector-tag">win_amd64</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="安装PyWin32"><a href="#安装PyWin32" class="headerlink" title="安装PyWin32"></a>安装PyWin32</h3>
                  <p>从官方网站下载对应版本的安装包即可，链接为：<a href="https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/" target="_blank" rel="noopener">https://sourceforge.net/projects/pywin32/files/pywin32/Build%20221/</a>，如图1-78所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-79.jpg" alt="">图1-78 下载列表</p>
                  <p>比如对于Python 3.6版本，可以选择下载pywin32-221.win-amd64-py3.6.exe，下载完毕之后双击安装即可。</p>
                  <p>注意，这里使用的是Build 221版本，随着时间推移，版本肯定会继续更新，最新的版本可以查看<a href="https://sourceforge.net/projects/pywin32/files/pywin32/" target="_blank" rel="noopener">https://sourceforge.net/projects/pywin32/files/pywin32/</a>，到时查找最新的版本安装即可。</p>
                  <h3 id="安装Scrapy"><a href="#安装Scrapy" class="headerlink" title="安装Scrapy"></a>安装Scrapy</h3>
                  <p>安装好了以上的依赖库后，安装Scrapy就非常简单了，这里依然使用pip，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>等待命令结束，如果没有报错，就证明Scrapy已经安装好了。</p>
                  <h2 id="4-Linux下的安装"><a href="#4-Linux下的安装" class="headerlink" title="4. Linux下的安装"></a>4. Linux下的安装</h2>
                  <p>在Linux下的安装方式依然分为两类平台来介绍。</p>
                  <h3 id="CentOS和Red-Hat"><a href="#CentOS和Red-Hat" class="headerlink" title="CentOS和Red Hat"></a>CentOS和Red Hat</h3>
                  <p>在CentOS和Red Hat下，首先确保一些依赖库已经安装，运行如下命令：</p>
                  <figure class="highlight gml">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum groupinstall -<span class="symbol">y</span> development tools</span><br><span class="line">sudo yum install -<span class="symbol">y</span> epel-release libxslt-devel libxml2-devel openssl-devel</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>最后利用pip安装Scrapy即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="Ubuntu、Debian和Deepin"><a href="#Ubuntu、Debian和Deepin" class="headerlink" title="Ubuntu、Debian和Deepin"></a>Ubuntu、Debian和Deepin</h3>
                  <p>在Ubuntu、Debian和Deepin平台下，首先确保一些依赖库已经安装，运行如下命令：</p>
                  <figure class="highlight q">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="built_in">get</span> install build-essential python3-<span class="built_in">dev</span> libssl-<span class="built_in">dev</span> libffi-<span class="built_in">dev</span> libxml2 libxml2-<span class="built_in">dev</span> libxslt1-<span class="built_in">dev</span> zlib1g-<span class="built_in">dev</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后利用pip安装Scrapy即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕后，就完成Scrapy的安装了。</p>
                  <h2 id="5-Mac下的安装"><a href="#5-Mac下的安装" class="headerlink" title="5. Mac下的安装"></a>5. Mac下的安装</h2>
                  <p>在Mac下，首先也是进行依赖库的安装。</p>
                  <p>在Mac上构建Scrapy的依赖库需要C编译器以及开发头文件，它一般由Xcode提供，具体命令如下：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>随后利用pip安装Scrapy即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> Scrapy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="6-验证安装"><a href="#6-验证安装" class="headerlink" title="6. 验证安装"></a>6. 验证安装</h2>
                  <p>安装之后，在命令行下输入<code>scrapy</code>，如果出现类似如图1-79所示的结果，就证明Scrapy安装成功了。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-80.jpg" alt="">图1-79 验证安装</p>
                  <h2 id="7-常见错误"><a href="#7-常见错误" class="headerlink" title="7. 常见错误"></a>7. 常见错误</h2>
                  <p>在安装过程中，常见的错误汇总如下。</p>
                  <h5 id="pkg-resources-VersionConflict-six-1-5-2-usr-lib-python3-dist-packages-Requirement-parse-39-six-gt-1-6-0-39"><a href="#pkg-resources-VersionConflict-six-1-5-2-usr-lib-python3-dist-packages-Requirement-parse-39-six-gt-1-6-0-39" class="headerlink" title="pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python3/dist-packages), Requirement.parse(&#39;six&gt;=1.6.0&#39;))"></a><code>pkg_resources.VersionConflict: (six 1.5.2 (/usr/lib/python3/dist-packages), Requirement.parse(&#39;six&gt;=1.6.0&#39;))</code></h5>
                  <p>这是six包版本过低出现的错误。six包是一个提供兼容Python 2和Python 3的库，这时升级six包即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo pip3 <span class="keyword">install</span> -U six</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h5 id="c-cffi-backend-c-15-17-fatal-error-ffi-h-No-such-file-or-directory"><a href="#c-cffi-backend-c-15-17-fatal-error-ffi-h-No-such-file-or-directory" class="headerlink" title="c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory"></a><code>c/_cffi_backend.c:15:17: fatal error: ffi.h: No such file or directory</code></h5>
                  <p>这是在Linux下常出现的错误，缺少libffi库造成的。什么是libffi？FFI的全名是Foreign Function Interface，通常指的是允许以一种语言编写的代码调用另一种语言的代码。而libffi库只提供了最底层的、与架构相关的、完整的FFI。此时安装相应的库即可。</p>
                  <p>在Ubuntu和Debian下，直接执行如下命令即可：</p>
                  <figure class="highlight q">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="built_in">get</span> install build-essential libssl-<span class="built_in">dev</span> libffi-<span class="built_in">dev</span> python3-<span class="built_in">dev</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在CentOS和Red Hat下，直接执行如下命令即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum <span class="keyword">install</span> gcc libffi-devel python-devel openssl-devel</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h5 id="Command-quot-python-setup-py-egg-info-quot-failed-with-error-code-1-in-tmp-pip-build-cryptography"><a href="#Command-quot-python-setup-py-egg-info-quot-failed-with-error-code-1-in-tmp-pip-build-cryptography" class="headerlink" title="Command &quot;python setup.py egg_info&quot; failed with error code 1 in /tmp/pip-build/cryptography/"></a><code>Command &quot;python setup.py egg_info&quot; failed with error code 1 in /tmp/pip-build/cryptography/</code></h5>
                  <p>这是缺少加密的相关组件，此时利用pip安装即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> cryptography</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h5 id="ImportError-No-module-named-39-packaging-39"><a href="#ImportError-No-module-named-39-packaging-39" class="headerlink" title="ImportError: No module named &#39;packaging&#39;"></a><code>ImportError: No module named &#39;packaging&#39;</code></h5>
                  <p>这是因为缺少packaging包出现的错误，这个包提供了Python包的核心功能，此时利用pip安装即可。</p>
                  <h5 id="ImportError-No-module-named-39-cffi-backend-39"><a href="#ImportError-No-module-named-39-cffi-backend-39" class="headerlink" title="ImportError: No module named &#39;_cffi_backend&#39;"></a><code>ImportError: No module named &#39;_cffi_backend&#39;</code></h5>
                  <p>这个错误表示缺少cffi包，直接使用pip安装即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> cffi</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h5 id="ImportError-No-module-named-39-pyparsing-39"><a href="#ImportError-No-module-named-39-pyparsing-39" class="headerlink" title="ImportError: No module named &#39;pyparsing&#39;"></a><code>ImportError: No module named &#39;pyparsing&#39;</code></h5>
                  <p>这个错误表示缺少pyparsing包，直接使用pip安装即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pyparsing appdirs</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 23:22:29" itemprop="dateCreated datePublished" datetime="2018-01-25T23:22:29+08:00">2018-01-25</time>
                </span>
                <span id="/5421.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.8.2-Scrapy的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3.1k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5416.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5416.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.8.1-pyspider的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>pyspider是国人binux编写的强大的网络爬虫框架，它带有强大的WebUI、脚本编辑器、任务监控器、项目管理器以及结果处理器，同时支持多种数据库后端、多种消息队列，另外还支持JavaScript渲染页面的爬取，使用起来非常方便，本节介绍一下它的安装过程。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方文档：<a href="http://docs.pyspider.org/" target="_blank" rel="noopener">http://docs.pyspider.org/</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/pyspider" target="_blank" rel="noopener">https://pypi.python.org/pypi/pyspider</a></li>
                    <li>GitHub：<a href="https://github.com/binux/pyspider" target="_blank" rel="noopener">https://github.com/binux/pyspider</a></li>
                    <li>官方教程：<a href="http://docs.pyspider.org/en/latest/tutorial" target="_blank" rel="noopener">http://docs.pyspider.org/en/latest/tutorial</a></li>
                    <li>在线实例：<a href="http://demo.pyspider.org/" target="_blank" rel="noopener">http://demo.pyspider.org</a></li>
                  </ul>
                  <h2 id="2-准备工作"><a href="#2-准备工作" class="headerlink" title="2. 准备工作"></a>2. 准备工作</h2>
                  <p>pyspider是支持JavaScript渲染的，而这个过程是依赖于PhantomJS的，所以还需要安装PhantomJS（具体的安装过程详见1.2.5节）。</p>
                  <h2 id="3-pip安装"><a href="#3-pip安装" class="headerlink" title="3. pip安装"></a>3. pip安装</h2>
                  <p>这里推荐使用pip安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pyspider</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>命令执行完毕即可完成安装。</p>
                  <h2 id="4-常见错误"><a href="#4-常见错误" class="headerlink" title="4. 常见错误"></a>4. 常见错误</h2>
                  <p>Windows下可能会出现这样的错误提示：</p>
                  <figure class="highlight applescript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">Command <span class="string">"python setup.py egg_info"</span> failed <span class="keyword">with</span> <span class="keyword">error</span> code <span class="number">1</span> <span class="keyword">in</span> /tmp/pip-build-vXo1W3/pycurl</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这是PyCurl安装错误，此时需要安装PyCurl库。从<a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycurl" target="_blank" rel="noopener">http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycurl</a>找到对应的Python版本，然后下载相应的wheel文件即可。比如Windows 64位、Python 3.6，则需要下载pycurl‑7.43.0‑cp36‑cp36m‑win_amd64.whl，随后用pip安装即可，命令如下：</p>
                  <figure class="highlight css">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="selector-tag">pip3</span> <span class="selector-tag">install</span> <span class="selector-tag">pycurl</span>‑7<span class="selector-class">.43</span><span class="selector-class">.0</span>‑<span class="selector-tag">cp36</span>‑<span class="selector-tag">cp36m</span>‑<span class="selector-tag">win_amd64</span><span class="selector-class">.whl</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果在Linux下遇到PyCurl的错误，可以参考本文：<a href="https://imlonghao.com/19.html" target="_blank" rel="noopener">https://imlonghao.com/19.html</a>。</p>
                  <h2 id="5-验证安装"><a href="#5-验证安装" class="headerlink" title="5. 验证安装"></a>5. 验证安装</h2>
                  <p>安装完成之后，可以直接在命令行下启动pyspider：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pyspider <span class="keyword">all</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>此时控制台会有类似如图1-74所示的输出。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-75.jpg" alt="">图1-74 控制台</p>
                  <p>这时pyspider的Web服务就会在本地5000端口运行。直接在浏览器中打开<a href="http://localhost:5000/" target="_blank" rel="noopener">http://localhost:5000/</a>，即可进入pyspider的WebUI管理页面，如图1-75所示，这证明pyspider已经安装成功了。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-76.png" alt="">图1-75 管理页面</p>
                  <p>后面，我们会详细介绍pyspider的用法。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 23:18:09" itemprop="dateCreated datePublished" datetime="2018-01-25T23:18:09+08:00">2018-01-25</time>
                </span>
                <span id="/5416.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.8.1-pyspider的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>1.1k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5413.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5413.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.8-爬虫框架的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>我们直接用Requests、Selenium等库写爬虫，如果爬取量不是太大，速度要求不高，是完全可以满足需求的。但是写多了会发现其内部许多代码和组件是可以复用的，如果我们把这些组件抽离出来，将各个功能模块化，就慢慢会形成一个框架雏形，久而久之，爬虫框架就诞生了。</p>
                  <p>利用框架，我们可以不用再去关心某些功能的具体实现，只需要关心爬取逻辑即可。有了它们，可以大大简化代码量，而且架构也会变得清晰，爬取效率也会高许多。所以，如果有一定的基础，上手框架是一种好的选择。</p>
                  <p>本书主要介绍的爬虫框架有pyspider和Scrapy。本节中，我们来介绍一下pyspider、Scrapy及其扩展库的安装方式。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 23:16:11" itemprop="dateCreated datePublished" datetime="2018-01-25T23:16:11+08:00">2018-01-25</time>
                </span>
                <span id="/5413.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.8-爬虫框架的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>293</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5407.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5407.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.7.3-Appium的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Appium是移动端的自动化测试工具，类似于前面所说的Selenium，利用它可以驱动Android、iOS等设备完成自动化测试，比如模拟点击、滑动、输入等操作，其官方网站为：<a href="http://appium.io/" target="_blank" rel="noopener">http://appium.io/</a>。本节中，我们就来了解一下Appium的安装方式。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/appium/appium" target="_blank" rel="noopener">https://github.com/appium/appium</a></li>
                    <li>官方网站：<a href="http://appium.io/" target="_blank" rel="noopener">http://appium.io</a></li>
                    <li>官方文档：<a href="http://appium.io/introduction.html" target="_blank" rel="noopener">http://appium.io/introduction.html</a></li>
                    <li>下载链接：<a href="https://github.com/appium/appium-desktop/releases" target="_blank" rel="noopener">https://github.com/appium/appium-desktop/releases</a></li>
                    <li>Python Client：<a href="https://github.com/appium/python-client" target="_blank" rel="noopener">https://github.com/appium/python-client</a></li>
                  </ul>
                  <h2 id="2-安装Appium"><a href="#2-安装Appium" class="headerlink" title="2. 安装Appium"></a>2. 安装Appium</h2>
                  <p>首先，需要安装Appium。Appium负责驱动移动端来完成一系列操作，对于iOS设备来说，它使用苹果的UIAutomation来实现驱动；对于Android来说，它使用UIAutomator和Selendroid来实现驱动。</p>
                  <p>同时Appium也相当于一个服务器，我们可以向它发送一些操作指令，它会根据不同的指令对移动设备进行驱动，以完成不同的动作。</p>
                  <p>安装Appium有两种方式，一种是直接下载安装包Appium Desktop来安装，另一种是通过Node.js来安装，下面我们介绍一下这两种安装方式。</p>
                  <h3 id="Appium-Desktop"><a href="#Appium-Desktop" class="headerlink" title="Appium Desktop"></a>Appium Desktop</h3>
                  <p>Appium Desktop支持全平台的安装，我们直接从GitHub的Releases里面安装即可，链接为<a href="https://github.com/appium/appium-desktop/releases" target="_blank" rel="noopener">https://github.com/appium/appium-desktop/releases</a>。目前的最新版本是1.1，下载页面如图1-71所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-72.jpg" alt="">图1-71 下载页面</p>
                  <p>Windows平台可以下载exe安装包appium-desktop-Setup-1.1.0.exe，Mac平台可以下载dmg安装包如appium-desktop-1.1.0.dmg，Linux平台可以选择下载源码，但是更推荐用Node.js安装方式。</p>
                  <p>安装完成后运行，看到的页面如图1-72所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-73.jpg" alt="">图1-72 运行页面</p>
                  <p>如果出现此页面，则证明安装成功。</p>
                  <h3 id="Node-js"><a href="#Node-js" class="headerlink" title="Node.js"></a>Node.js</h3>
                  <p>首先需要安装Node.js，具体的安装方式可以参见<a href="http://www.runoob.com/nodejs/nodejs-install-setup.html" target="_blank" rel="noopener">http://www.runoob.com/nodejs/nodejs-install-setup.html</a>，安装完成之后就可以使用<code>npm</code>命令了。</p>
                  <p>接下来，使用<code>npm</code>命令全局安装Appium即可：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">npm <span class="keyword">install</span> -g appium</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>此时等待命令执行完成即可，这样就成功安装了Appium。</p>
                  <h2 id="3-Android开发环境配置"><a href="#3-Android开发环境配置" class="headerlink" title="3. Android开发环境配置"></a>3. Android开发环境配置</h2>
                  <p>如果我们要使用Android设备做App抓取的话，还需要下载和配置Android SDK，这里推荐直接安装Android Studio，其下载地址为<a href="https://developer.android.com/studio/index.html?hl=zh-cn" target="_blank" rel="noopener">https://developer.android.com/studio/index.html?hl=zh-cn</a>。下载后直接安装即可。</p>
                  <p>然后，我们还需要下载Android SDK。直接打开首选项里面的Android SDK设置页面，勾选要安装的SDK版本，点击OK按钮即可下载和安装勾选的SDK版本，如图1-73所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-74.jpg" alt="">图1-73 Android SDK设置页面</p>
                  <p>另外，还需要配置一下环境变量，添加ANDROID_HOME为Android SDK所在路径，然后再添加SDK文件夹下的tools和platform-tools文件夹到PATH中。</p>
                  <p>更详细的配置可以参考Android Studio的官方文档：<a href="https://developer.android.com/studio/intro/index.html" target="_blank" rel="noopener">https://developer.android.com/studio/intro/index.html</a>。</p>
                  <h2 id="4-iOS开发环境"><a href="#4-iOS开发环境" class="headerlink" title="4. iOS开发环境"></a>4. iOS开发环境</h2>
                  <p>首先需要声明的是，Appium是一个做自动化测试的工具，用它来测试我们自己开发的App是完全没问题的，因为它携带的是开发证书（Development Certificate）。但如果我们想拿iOS设备来做数据爬取的话，那又是另外一回事了。一般情况下，我们做数据爬取都是使用现有的App，在iOS上一般都是通过App Store下载的，它携带的是分发证书（Distribution Certificate），而携带这种证书的应用都是禁止被测试的，所以只有获取ipa安装包再重新签名之后才可以被Appium测试，具体的方法这里不再展开阐述。</p>
                  <p>这里推荐直接使用Android来进行测试。如果你可以完成上述重签名操作，那么可以参考如下内容配置iOS开发环境。</p>
                  <p>Appium驱动iOS设备必须要在Mac下进行，Windows和Linux平台是无法完成的，所以下面介绍一下Mac平台的相关配置。</p>
                  <p>Mac平台需要的配置如下：</p>
                  <ul>
                    <li>macOS 10.12及更高版本</li>
                    <li>XCode 8及更高版本</li>
                  </ul>
                  <p>配置满足要求之后，执行如下命令即可配置开发依赖的一些库和工具：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">xcode-<span class="keyword">select</span> <span class="comment">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样iOS部分的开发环境就配置完成了，我们就可以用iOS模拟器来进行测试和数据抓取了。</p>
                  <p>如果想要用真机进行测试和数据抓取，还需要额外配置其他环境，具体可以参考<a href="https://github.com/appium/appium/blob/master/docs/en/appium-setup/real-devices-ios.md" target="_blank" rel="noopener">https://github.com/appium/appium/blob/master/docs/en/appium-setup/real-devices-ios.md</a>。</p>
                  <h2 id="5-Python-驱动"><a href="#5-Python-驱动" class="headerlink" title="5. Python 驱动"></a>5. Python 驱动</h2>
                  <p>另外还需要安装 Python 驱动，命令如下：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> appium-python-<span class="keyword">client</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 23:08:18" itemprop="dateCreated datePublished" datetime="2018-01-25T23:08:18+08:00">2018-01-25</time>
                </span>
                <span id="/5407.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.7.3-Appium的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2.2k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5391.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5391.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.7.2-mitmproxy的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>mitmproxy是一个支持HTTP和HTTPS的抓包程序，类似Fiddler、Charles的功能，只不过它通过控制台的形式操作。</p>
                  <p>此外，mitmproxy还有两个关联组件，一个是mitmdump，它是mitmproxy的命令行接口，利用它可以对接Python脚本，实现监听后的处理；另一个是mitmweb，它是一个Web程序，通过它以清楚地观察到mitmproxy捕获的请求。</p>
                  <p>本节中，我们就来了解一下mitmproxy、mitmdump和mitmweb的安装方式。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/mitmproxy/mitmproxy" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy</a></li>
                    <li>官方网站：<a href="https://mitmproxy.org/" target="_blank" rel="noopener">https://mitmproxy.org</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/mitmproxy" target="_blank" rel="noopener">https://pypi.python.org/pypi/mitmproxy</a></li>
                    <li>官方文档：<a href="http://docs.mitmproxy.org/" target="_blank" rel="noopener">http://docs.mitmproxy.org</a></li>
                    <li>mitmdump脚本：<a href="http://docs.mitmproxy.org/en/stable/scripting/overview.html" target="_blank" rel="noopener">http://docs.mitmproxy.org/en/stable/scripting/overview.html</a></li>
                    <li>下载地址：<a href="https://github.com/mitmproxy/mitmproxy/releases" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy/releases</a></li>
                    <li>DockerHub：<a href="https://hub.docker.com/r/mitmproxy/mitmproxy" target="_blank" rel="noopener">https://hub.docker.com/r/mitmproxy/mitmproxy</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>最简单的安装方式还是使用pip，直接执行如下命令即可安装：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> mitmproxy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这是最简单和通用的安装方式，执行完毕之后即可完成mitmproxy的安装，另外还附带安装了mitmdump和mitmweb这两个组件。如果不想用这种方式安装，也可以选择后面列出的专门针对各个平台的安装方式或者Docker安装方式。</p>
                  <h2 id="3-Windows下的安装"><a href="#3-Windows下的安装" class="headerlink" title="3. Windows下的安装"></a>3. Windows下的安装</h2>
                  <p>可以到GitHub上的Releases页面（链接为：<a href="https://github.com/mitmproxy/mitmproxy/releases/" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy/releases/</a>）获取安装包，如图1-59所示。 <img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-60.jpg" alt="">图1-59 下载页面</p>
                  <p>比如，当前的最新版本为2.0.2，则可以选择下载Windows下的exe安装包mitmproxy-2.0.2-windows-installer.exe，下载后直接双击安装包即可安装。</p>
                  <p>注意，在Windows上不支持mitmproxy的控制台接口，但是可以使用mitmdump和mitmweb。</p>
                  <h2 id="4-Linux下的安装"><a href="#4-Linux下的安装" class="headerlink" title="4. Linux下的安装"></a>4. Linux下的安装</h2>
                  <p>在Linux下，可以下载编译好的二进制包（下载地址<a href="https://github.com/mitmproxy/mitmproxy/releases/" target="_blank" rel="noopener">https://github.com/mitmproxy/mitmproxy/releases/</a>），此发行包一般是最新版本，它包含了最新版本的mitmproxy和内置的Python 3环境，以及最新的OpenSSL环境。</p>
                  <p>如果你的环境里没有Python 3和OpenSSL环境，建议使用此种方式安装。</p>
                  <p>下载之后，需要解压并将其配置到环境变量：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">tar -zxvf mitmproxy<span class="number">-2.0</span><span class="number">.2</span>-linux.tar.gz</span><br><span class="line">sudo mv mitmproxy mitmdump mitmweb /usr/bin</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就可以将3个可执行文件移动到了/usr/bin目录。而一般情况下，/usr/bin目录都已经配置在了环境变量下，所以接下来可以直接调用这3个工具了。</p>
                  <h2 id="5-Mac下的安装"><a href="#5-Mac下的安装" class="headerlink" title="5. Mac下的安装"></a>5. Mac下的安装</h2>
                  <p>Mac下的安装非常简单，直接使用Homebrew即可，命令如下：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>mitmproxy</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行命令后，即可完成mitmproxy的安装。</p>
                  <h2 id="6-Docker安装"><a href="#6-Docker安装" class="headerlink" title="6. Docker安装"></a>6. Docker安装</h2>
                  <p>mitmproxy也支持Docker，其DockerHub的地址为<a href="https://hub.docker.com/r/mitmproxy/mitmproxy/" target="_blank" rel="noopener">https://hub.docker.com/r/mitmproxy/mitmproxy/</a>。</p>
                  <p>在Docker下，mitmproxy的安装命令为：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run --rm -it -p <span class="number">8080</span>:<span class="number">8080</span> mitmproxy/mitmproxy mitmdump</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就在8080端口上启动了mitmproxy和mitmdump。</p>
                  <p>如果想要获取CA证书，可以选择挂载磁盘选项，命令如下：</p>
                  <figure class="highlight jboss-cli">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run <span class="params">--rm</span> -it -v ~<span class="string">/.mitmproxy</span>:<span class="string">/home/mitmproxy/.mitmproxy</span> -p 8080<span class="function">:8080</span> mitmproxy/mitmproxy mitmdump</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就可以在~/.mitmproxy目录下找到CA证书。</p>
                  <p>另外，还可以在8081端口上启动mitmweb，命令如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">docker run --rm -it -p <span class="number">8080</span>:<span class="number">8080</span> -p <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span>:<span class="number">8081</span>:<span class="number">8081</span> mitmproxy/mitmproxy mitmweb</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>更多启动方式可以参考Docker Hub的安装说明。</p>
                  <h2 id="7-证书配置"><a href="#7-证书配置" class="headerlink" title="7. 证书配置"></a>7. 证书配置</h2>
                  <p>对于mitmproxy来说，如果想要截获HTTPS请求，就需要设置证书。mitmproxy在安装后会提供一套CA证书，只要客户端信任了mitmproxy提供的证书，就可以通过mitmproxy获取HTTPS请求的具体内容，否则mitmproxy是无法解析HTTPS请求的。</p>
                  <p>首先，运行以下命令产生CA证书，并启动mitmdump：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">mitmdump</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>接下来，我们就可以在用户目录下的.mitmproxy目录里面找到CA证书，如图1-60所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-61.jpg" alt="">图1-60 证书文件</p>
                  <p>证书一共5个，表1-1简要说明了这5个证书。</p>
                  <p>表1-1 5个证书及其说明</p>
                  <p>名称</p>
                  <p>描述</p>
                  <p>mitmproxy-ca.pem</p>
                  <p>PEM格式的证书私钥</p>
                  <p>mitmproxy-ca-cert.pem</p>
                  <p>PEM格式证书，适用于大多数非Windows平台</p>
                  <p>mitmproxy-ca-cert.p12</p>
                  <p>PKCS12格式的证书，适用于Windows平台</p>
                  <p>mitmproxy-ca-cert.cer</p>
                  <p>与mitmproxy-ca-cert.pem相同，只是改变了后缀，适用于部分Android平台</p>
                  <p>mitmproxy-dhparam.pem</p>
                  <p>PEM格式的秘钥文件，用于增强SSL安全性</p>
                  <p>下面我们介绍一下Windows、Mac、iOS和Android平台下的证书配置过程。</p>
                  <h3 id="Windows"><a href="#Windows" class="headerlink" title="Windows"></a>Windows</h3>
                  <p>双击mitmproxy-ca.p12，就会出现导入证书的引导页，如图1-61所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-62.jpg" alt="">图1-61 证书导入向导</p>
                  <p>直接点击“下一步”按钮即可，会出现密码设置提示，如图1-62所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-63.jpg" alt="">图1-62 密码设置提示</p>
                  <p>这里不需要设置密码，直接点击“下一步”按钮即可。</p>
                  <p>接下来需要选择证书的存储区域，如图1-63所示。这里点击第二个选项“将所有的证书都放入下列存储”，然后点击“浏览”按钮，选择证书存储位置为“受信任的根证书颁发机构”，接着点击“确定”按钮，然后点击“下一步”按钮。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-64.jpg" alt="">图1-63 选择证书存储区域</p>
                  <p>最后，如果有安全警告弹出，如图1-64所示，直接点击“是”按钮即可。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-65.jpg" alt="">图1-64 安全警告</p>
                  <p>这样就在Windows下配置完CA证书了。</p>
                  <h3 id="Mac"><a href="#Mac" class="headerlink" title="Mac"></a>Mac</h3>
                  <p>Mac下双击mitmproxy-ca-cert.pem即可弹出钥匙串管理页面，然后找到mitmproxy证书，打开其设置选项，选择“始终信任”即可，如图1-65所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-66.jpg" alt="">图1-65 证书配置</p>
                  <h3 id="iOS"><a href="#iOS" class="headerlink" title="iOS"></a>iOS</h3>
                  <p>将mitmproxy-ca-cert.pem文件发送到iPhone上，推荐使用邮件方式发送，然后在iPhone上可以直接点击附件并识别安装，如图1-66所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-67.jpg" alt="">图1-66 证书安装页面</p>
                  <p>点击“安装”按钮之后，会跳到安装描述文件的页面，点击“安装”按钮，此时会有警告提示，如图1-67所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-68.jpg" alt="">图1-67 安装警告页面</p>
                  <p>继续点击右上角的“安装”按钮，安装成功之后会有已安装的提示，如图1-68所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-69.jpg" alt="">图1-68 安装成功页面</p>
                  <p>如果你的iOS版本是10.3以下的话，此处信任CA证书的流程就已经完成了。</p>
                  <p>如果你的iOS版本是10.3及以上版本，还需要在“设置”→“通用”→“关于本机”→“证书信任设置”将mitmproxy的完全信任开关打开，如图1-69所示。此时，在iOS上配置信任CA证书的流程就结束了。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-70.jpg" alt="">图1-69 证书信任设置</p>
                  <h3 id="Android"><a href="#Android" class="headerlink" title="Android"></a>Android</h3>
                  <p>在Android手机上，同样需要将证书mitmproxy-ca-cert.pem文件发送到手机上，例如直接复制文件。</p>
                  <p>接下来，点击证书，便会出现一个提示窗口，如图1-70所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-71.jpg" alt="">图1-70 证书安装页面</p>
                  <p>这时输入证书的名称，然后点击“确定”按钮即可完成安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 21:52:23" itemprop="dateCreated datePublished" datetime="2018-01-25T21:52:23+08:00">2018-01-25</time>
                </span>
                <span id="/5391.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.7.2-mitmproxy的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>3.3k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>3 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5255.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5255.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.7.1-Charles的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Charles是一个网络抓包工具，相比Fiddler，其功能更为强大，而且跨平台支持得更好，所以这里选用它来作为主要的移动端抓包工具。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.charlesproxy.com/" target="_blank" rel="noopener">https://www.charlesproxy.com</a></li>
                    <li>下载链接：<a href="https://www.charlesproxy.com/download" target="_blank" rel="noopener">https://www.charlesproxy.com/download</a></li>
                  </ul>
                  <h2 id="2-下载Charles"><a href="#2-下载Charles" class="headerlink" title="2. 下载Charles"></a>2. 下载Charles</h2>
                  <p>我们可以在官网下载最新的稳定版本，如图1-43所示。可以发现，它支持Windows、Linux和Mac三大平台。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-43.jpg" alt="">图1-43 Charles下载页面</p>
                  <p>直接点击对应的安装包下载即可，具体的安装过程这里不再赘述。</p>
                  <p>Charles是收费软件，不过可以免费试用30天。如果试用期过了，其实还可以试用，不过每次试用不能超过30分钟，启动有10秒的延时，但是完整的软件功能还是可以使用的，所以还算比较友好。</p>
                  <h2 id="3-证书配置"><a href="#3-证书配置" class="headerlink" title="3. 证书配置"></a>3. 证书配置</h2>
                  <p>现在很多页面都在向HTTPS方向发展，HTTPS通信协议应用得越来越广泛。如果一个App通信应用了HTTPS协议，那么它通信的数据都会是被加密的，常规的截包方法是无法识别请求内部的数据的。</p>
                  <p>安装完成后，如果我们想要做HTTPS抓包的话，那么还需要配置一下相关SSL证书。接下来，我们再看看各个平台下的证书配置过程。</p>
                  <p>Charles是运行在PC端的，我们要抓取的是App端的数据，所以要在PC和手机端都安装证书。</p>
                  <h3 id="Windows"><a href="#Windows" class="headerlink" title="Windows"></a>Windows</h3>
                  <p>如果你的PC是Windows系统，可以按照下面的操作进行证书配置。</p>
                  <p>首先打开Charles，点击Help→SSL Proxying→Install Charles Root Certificate，即可进入证书的安装页面，如图1-44所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-44.jpg" alt="">图1-44 证书安装页面入口</p>
                  <p>接下来，会弹出一个安装证书的页面，如图1-45 所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-45.jpg" alt="">图1-45 证书安装页面</p>
                  <p>点击“安装证书”按钮，就会打开证书导入向导，如图1-46所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-46.jpg" alt="">图1-46 证书导入向导</p>
                  <p>直接点击“下一步”按钮，此时需要选择证书的存储区域，点击第二个选项“将所有的证书放入下列存储”，然后点击“浏览”按钮，从中选择证书存储位置为“受信任的根证书颁发机构”，再点击“确定”按钮，然后点击“下一步”按钮，如图1-47所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-47.jpg" alt="">图1-47 选择证书存储区域</p>
                  <p>再继续点击“下一步”按钮完成导入。</p>
                  <h3 id="Mac"><a href="#Mac" class="headerlink" title="Mac"></a>Mac</h3>
                  <p>如果你的PC是Mac系统，可以按照下面的操作进行证书配置。</p>
                  <p>同样是点击Help→SSL Proxying→Install Charles Root Certificate，即可进入证书的安装页面。</p>
                  <p>接下来，找到Charles的证书并双击，将“信任”设置为“始终信任”即可，如图1-48所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-48.jpg" alt="">图1-48 证书配置</p>
                  <p>这样就成功安装了证书。</p>
                  <h3 id="iOS"><a href="#iOS" class="headerlink" title="iOS"></a>iOS</h3>
                  <p>如果你的手机是iOS系统，可以按照下面的操作进行证书配置。</p>
                  <p>首先，查看电脑的Charles代理是否开启，具体操作是点击Proxy→Proxy Settings，打开代理设置页面，确保当前的HTTP代理是开启的，如图1-49所示。这里的代理端口为8888，也可以自行修改。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-49.png" alt="">图1-49 代理设置</p>
                  <p>接下来，将手机和电脑连在同一个局域网下。例如，当前电脑的IP为192.168.1.76，那么首先设置手机的代理为192.168.1.76:8888，如图1-50所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-50.jpg" alt="">图1-50 代理设置</p>
                  <p>设置完毕后，电脑上会出现一个提示窗口，询问是否信任此设备，如图1-51所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-51.png" alt="">图1-51 提示窗口</p>
                  <p>此时点击Allow按钮即可。这样手机就和PC连在同一个局域网内了，而且设置了Charles的代理，即Charles可以抓取到流经App的数据包了。</p>
                  <p>接下来，再安装Charles的HTTPS证书。</p>
                  <p>在电脑上打开Help→SSL Proxying→Install Charles Root Certificate on a Mobile Device or Remote Browser，如图1-52所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-52.jpg" alt="">图1-52 证书安装页面入口</p>
                  <p>此时会看到如图1-53所示的提示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-53.png" alt="">图1-53 提示窗口</p>
                  <p>它提示我们在手机上设置好Charles的代理（刚才已经设置好了），然后在手机浏览器中打开chls.pro/ssl下载证书。</p>
                  <p>在手机上打开chls.pro/ssl后，便会弹出证书的安装页面，如图1-54所示：</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-54.jpg" alt="">图1-54 证书安装页面</p>
                  <p>点击“安装”按钮，然后输入密码即可完成安装，如图1-55所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-55.jpg" alt="">图1-55 安装成功页面</p>
                  <p>如果你的iOS版本是10.3以下的话，信任CA证书的流程就已经完成了。</p>
                  <p>如果你的iOS版本是10.3及以上，还需要在“设置”→“通用”→“关于本机”→“证书信任设置”中将证书的完全信任开关打开，如图1-56所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-56.jpg" alt="">图1-56 证书信任设置</p>
                  <h3 id="Android"><a href="#Android" class="headerlink" title="Android"></a>Android</h3>
                  <p>如果你的手机是Android系统，可以按照下面的操作进行证书配置。</p>
                  <p>在Android系统中，同样需要设置代理为Charles的代理，如图1-57所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-57.jpg" alt="">图1-57 代理设置</p>
                  <p>设置完毕后，电脑上就会出现一个提示窗口，询问是否信任此设备，如图1-51所示，此时直接点击Allow按钮即可。</p>
                  <p>接下来，像iOS设备那样，在手机浏览器上打开chls.pro/ssl，这时会出现一个提示框，如图1-58所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-58.png" alt="">图1-58 证书安装页面</p>
                  <p>我们为证书添加一个名称，然后点击“确定”按钮即可完成证书的安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 18:25:21" itemprop="dateCreated datePublished" datetime="2018-01-25T18:25:21+08:00">2018-01-25</time>
                </span>
                <span id="/5255.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.7.1-Charles的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2.1k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5252.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5252.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.7-App爬取相关库的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>除了Web网页，爬虫也可以抓取App的数据。App中的页面要加载出来，首先需要获取数据，而这些数据一般是通过请求服务器的接口来获取的。由于App没有浏览器这种可以比较直观地看到后台请求的工具，所以主要用一些抓包技术来抓取数据。</p>
                  <p>本书介绍的抓包工具有Charles、mitmproxy和mitmdump。一些简单的接口可以通过Charles或mitmproxy分析，找出规律，然后直接用程序模拟来抓取了。但是如果遇到更复杂的接口，就需要利用mitmdump对接Python来对抓取到的请求和响应进行实时处理和保存。另外，既然要做规模采集，就需要自动化App的操作而不是人工去采集，所以这里还需要一个工具叫作Appium，它可以像Selenium一样对App进行自动化控制，如自动化模拟App的点击、下拉等操作。</p>
                  <p>本节中，我们就来介绍一下Charles、mitmproxy、mitmdump、Appium的安装方法。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 18:23:01" itemprop="dateCreated datePublished" datetime="2018-01-25T18:23:01+08:00">2018-01-25</time>
                </span>
                <span id="/5252.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.7-App爬取相关库的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>404</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5248.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5248.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.6.2-Tornado的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Tornado是一个支持异步的Web框架，通过使用非阻塞I/O流，它可以支撑成千上万的开放连接，效率非常高，本节就来介绍一下它的安装方式。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/tornadoweb/tornado" target="_blank" rel="noopener">https://github.com/tornadoweb/tornado</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/tornado" target="_blank" rel="noopener">https://pypi.python.org/pypi/tornado</a></li>
                    <li>官方文档：<a href="http://www.tornadoweb.org/" target="_blank" rel="noopener">http://www.tornadoweb.org</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>这里推荐使用pip安装，相关命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> tornado</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行完毕后，即可完成安装。</p>
                  <h2 id="3-验证安装"><a href="#3-验证安装" class="headerlink" title="3. 验证安装"></a>3. 验证安装</h2>
                  <p>同样，这里也可以用一个Hello World程序测试一下，代码如下：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">import</span> tornado.ioloop</span><br><span class="line"><span class="keyword">import</span> tornado.web</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">MainHandler</span><span class="params">(tornado.web.RequestHandler)</span>:</span></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">get</span><span class="params">(self)</span>:</span></span><br><span class="line">        self.write(<span class="string">"Hello, world"</span>)</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">make_app</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="keyword">return</span> tornado.web.Application([</span><br><span class="line">        (<span class="string">r"/"</span>, MainHandler),</span><br><span class="line">    ])</span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">"__main__"</span>:</span><br><span class="line">    app = make_app()</span><br><span class="line">    app.listen(<span class="number">8888</span>)</span><br><span class="line">    tornado.ioloop.IOLoop.current().start()</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>直接运行程序，可以发现系统在8888端口运行了Web服务，控制台没有输出内容，此时访问<a href="http://127.0.0.1:8888/" target="_blank" rel="noopener">http://127.0.0.1:8888/</a>，可以观察到网页中呈现了Hello,world，如图1-42所示，这就说明Tornado成功安装了。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-42.png" alt="">图1-42 运行结果</p>
                  <h2 id="4-结语"><a href="#4-结语" class="headerlink" title="4.结语"></a>4.结语</h2>
                  <p>后面，我们会利用Tornado+Redis来搭建一个ADSL拨号代理池。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 18:19:14" itemprop="dateCreated datePublished" datetime="2018-01-25T18:19:14+08:00">2018-01-25</time>
                </span>
                <span id="/5248.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.6.2-Tornado的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>752</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5244.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5244.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.6.1-Flask的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Flask是一个轻量级的Web服务程序，它简单、易用、灵活，这里主要用来做一些API服务。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/pallets/flask" target="_blank" rel="noopener">https://github.com/pallets/flask</a></li>
                    <li>官方文档：<a href="http://flask.pocoo.org/" target="_blank" rel="noopener">http://flask.pocoo.org</a></li>
                    <li>中文文档：<a href="http://docs.jinkan.org/docs/flask" target="_blank" rel="noopener">http://docs.jinkan.org/docs/flask</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/Flask" target="_blank" rel="noopener">https://pypi.python.org/pypi/Flask</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>这里推荐使用pip安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> flask</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕后，就完成安装了。</p>
                  <h2 id="3-验证安装"><a href="#3-验证安装" class="headerlink" title="3. 验证安装"></a>3. 验证安装</h2>
                  <p>安装成功后，可以运行如下实例代码测试一下：</p>
                  <figure class="highlight python">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">from</span> flask <span class="keyword">import</span> Flask</span><br><span class="line">app = Flask(__name__)</span><br><span class="line"></span><br><span class="line"><span class="meta">@app.route("/")</span></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">hello</span><span class="params">()</span>:</span></span><br><span class="line">    <span class="keyword">return</span> <span class="string">"Hello World!"</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">"__main__"</span>:</span><br><span class="line">    app.run()</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>可以发现，系统会在5000端口开启Web服务，控制台输出如下：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">* Running <span class="keyword">on</span> http://<span class="number">127.0</span>.<span class="number">0.1</span>:<span class="number">5000</span>/ (Press CTRL+C <span class="keyword">to</span> <span class="keyword">quit</span>)</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>直接访问<a href="http://127.0.0.1:5000/" target="_blank" rel="noopener">http://127.0.0.1:5000/</a>，可以观察到网页中呈现了Hello World!，如图1-41所示，一个最简单的Flask程序就运行成功了。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-41.png" alt="">图1-41 运行结果</p>
                  <h2 id="4-结语"><a href="#4-结语" class="headerlink" title="4. 结语"></a>4. 结语</h2>
                  <p>后面，我们会利用Flask+Redis维护动态代理池和Cookies池。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 18:08:58" itemprop="dateCreated datePublished" datetime="2018-01-25T18:08:58+08:00">2018-01-25</time>
                </span>
                <span id="/5244.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.6.1-Flask的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>611</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5239.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5239.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.6-Web库的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>对于Web，我们应该都不陌生，现在日常访问的网站都是Web服务程序搭建而成的。Python同样不例外，也有一些这样的Web服务程序，比如Flask、Django等，我们可以拿它来开发网站和接口等。</p>
                  <p>在本书中，我们主要使用这些Web服务程序来搭建一些API接口，供我们的爬虫使用。例如，维护一个代理池，代理保存在Redis数据库中，我们要将代理池作为一个公共的组件使用，那么如何构建一个方便的平台来供我们获取这些代理呢？最合适不过的就是通过Web服务提供一个API接口，我们只需要请求接口即可获取新的代理，这样做简单、高效、实用！</p>
                  <p>书中用到的一些Web服务程序主要有Flask和Tornado，这里就分别介绍它们的安装方法。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 17:47:41" itemprop="dateCreated datePublished" datetime="2018-01-25T17:47:41+08:00">2018-01-25</time>
                </span>
                <span id="/5239.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.6-Web库的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>309</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5236.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5236.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.5.4-RedisDump的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>RedisDump是一个用于Redis数据导入/导出的工具，是基于Ruby实现的，所以要安装RedisDump，需要先安装Ruby。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/delano/redis-dump" target="_blank" rel="noopener">https://github.com/delano/redis-dump</a></li>
                    <li>官方文档：<a href="http://delanotes.com/redis-dump" target="_blank" rel="noopener">http://delanotes.com/redis-dump</a></li>
                  </ul>
                  <h2 id="2-安装Ruby"><a href="#2-安装Ruby" class="headerlink" title="2. 安装Ruby"></a>2. 安装Ruby</h2>
                  <p>有关Ruby的安装方式可以参考<a href="http://www.ruby-lang.org/zh_cn/documentation/installation" target="_blank" rel="noopener">http://www.ruby-lang.org/zh_cn/documentation/installation</a>，这里列出了所有平台的安装方式，可以根据对应的平台选用合适的安装方式。</p>
                  <h2 id="3-gem安装"><a href="#3-gem安装" class="headerlink" title="3. gem安装"></a>3. <code>gem</code>安装</h2>
                  <p>安装完成之后，就可以执行<code>gem</code>命令了，它类似于Python中的<code>pip</code>命令。利用<code>gem</code>命令，我们可以安装RedisDump，具体如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">gem <span class="keyword">install</span> redis-dump</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行完毕之后，即可完成RedisDump的安装。</p>
                  <h2 id="4-验证安装"><a href="#4-验证安装" class="headerlink" title="4. 验证安装"></a>4. 验证安装</h2>
                  <p>安装成功后，就可以执行如下两个命令：</p>
                  <figure class="highlight lua">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">redis-<span class="built_in">dump</span></span><br><span class="line">redis-<span class="built_in">load</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果可以成功调用，则证明安装成功。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:42:45" itemprop="dateCreated datePublished" datetime="2018-01-25T15:42:45+08:00">2018-01-25</time>
                </span>
                <span id="/5236.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.5.4-RedisDump的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>447</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5233.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5233.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.5.3-redis-py的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>对于Redis来说，我们要使用redis-py库来与其交互，这里就来介绍一下它的安装方法。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/andymccurdy/redis-py" target="_blank" rel="noopener">https://github.com/andymccurdy/redis-py</a></li>
                    <li>官方文档：<a href="https://redis-py.readthedocs.io/" target="_blank" rel="noopener">https://redis-py.readthedocs.io/</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>这里推荐使用pip安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后，即可完成redis-py的安装。</p>
                  <h2 id="3-验证安装"><a href="#3-验证安装" class="headerlink" title="3. 验证安装"></a>3. 验证安装</h2>
                  <p>为了验证redis-py库是否已经安装成功，可以在命令行下测试一下：</p>
                  <figure class="highlight ruby">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; import redis</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; redis.VERSION</span><br><span class="line">(<span class="number">2</span>, <span class="number">10</span>, <span class="number">5</span>)</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果成功输出了其版本内容，那么证明成功安装了redis-py。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:39:57" itemprop="dateCreated datePublished" datetime="2018-01-25T15:39:57+08:00">2018-01-25</time>
                </span>
                <span id="/5233.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.5.3-redis-py的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>350</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5230.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5230.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.5.2-PyMongo的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>在Python中，如果想要和MongoDB进行交互，就需要借助于PyMongo库，这里就来了解一下它的安装方法。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/mongodb/mongo-python-driver" target="_blank" rel="noopener">https://github.com/mongodb/mongo-python-driver</a></li>
                    <li>官方文档：<a href="https://api.mongodb.com/python/current/" target="_blank" rel="noopener">https://api.mongodb.com/python/current/</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/pymongo" target="_blank" rel="noopener">https://pypi.python.org/pypi/pymongo</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>这里推荐使用pip安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pymongo</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行完毕之后，即可完成PyMongo的安装。</p>
                  <h2 id="3-验证安装"><a href="#3-验证安装" class="headerlink" title="3. 验证安装"></a>3. 验证安装</h2>
                  <p>为了验证PyMongo库是否已经安装成功，可以在命令行下测试一下：</p>
                  <figure class="highlight ruby">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; import pymongo</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; pymongo.version</span><br><span class="line"><span class="string">'3.4.0'</span></span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果成功输出了其版本内容，那么证明成功安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:37:18" itemprop="dateCreated datePublished" datetime="2018-01-25T15:37:18+08:00">2018-01-25</time>
                </span>
                <span id="/5230.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.5.2-PyMongo的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>410</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5227.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5227.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.5.1-PyMySQL的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>在Python 3中，如果想要将数据存储到MySQL中，就需要借助PyMySQL来操作，本节中我们介绍一下它的安装方式。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>GitHub：<a href="https://github.com/PyMySQL/PyMySQL" target="_blank" rel="noopener">https://github.com/PyMySQL/PyMySQL</a></li>
                    <li>官方文档：<a href="http://pymysql.readthedocs.io/" target="_blank" rel="noopener">http://pymysql.readthedocs.io/</a></li>
                    <li>PyPI：<a href="https://pypi.python.org/pypi/PyMySQL" target="_blank" rel="noopener">https://pypi.python.org/pypi/PyMySQL</a></li>
                  </ul>
                  <h2 id="2-pip安装"><a href="#2-pip安装" class="headerlink" title="2. pip安装"></a>2. pip安装</h2>
                  <p>这里推荐使用pip安装，命令如下：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">pip3 <span class="keyword">install</span> pymysql</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>执行完命令后即可完成安装。</p>
                  <h2 id="3-验证安装"><a href="#3-验证安装" class="headerlink" title="3. 验证安装"></a>3. 验证安装</h2>
                  <p>为了验证库是否已经安装成功，可以在命令行下测试一下。这里首先输入<code>python3</code>，进入命令行模式，接着输入如下内容：</p>
                  <figure class="highlight ruby">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ python3</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; import pymysql</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt; pymysql.VERSION</span><br><span class="line">(<span class="number">0</span>, <span class="number">7</span>, <span class="number">11</span>, None)</span><br><span class="line"><span class="meta">&gt;&gt;</span>&gt;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>如果成功输出了其版本内容，那么证明PyMySQL成功安装。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:34:32" itemprop="dateCreated datePublished" datetime="2018-01-25T15:34:32+08:00">2018-01-25</time>
                </span>
                <span id="/5227.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.5.1-PyMySQL的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>420</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5224.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5224.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.5-存储库的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>1.4节中，我们介绍了几个数据库的安装方式，但这仅仅是用来存储数据的数据库，它们提供了存储服务，但如果想要和Python交互的话，还需要安装一些Python存储库，如MySQL需要安装PyMySQL，MongoDB需要安装PyMongo等。本节中，我们来说明一下这些存储库的安装方式。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:29:47" itemprop="dateCreated datePublished" datetime="2018-01-25T15:29:47+08:00">2018-01-25</time>
                </span>
                <span id="/5224.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.5-存储库的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>142</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5219.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5219.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.4.3-Redis的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>Redis是一个基于内存的高效的非关系型数据库，本节中我们来了解一下它在各个平台的安装过程。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://redis.io/" target="_blank" rel="noopener">https://redis.io</a></li>
                    <li>官方文档：<a href="https://redis.io/documentation" target="_blank" rel="noopener">https://redis.io/documentation</a></li>
                    <li>中文官网：<a href="http://www.redis.cn/" target="_blank" rel="noopener">http://www.redis.cn</a></li>
                    <li>GitHub：<a href="https://github.com/antirez/redis" target="_blank" rel="noopener">https://github.com/antirez/redis</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/redis/redis-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/redis/redis-tutorial.html</a></li>
                    <li>Redis Desktop Manager：<a href="https://redisdesktop.com/" target="_blank" rel="noopener">https://redisdesktop.com</a></li>
                    <li>Redis Desktop Manager GitHub：<a href="https://github.com/uglide/RedisDesktopManager" target="_blank" rel="noopener">https://github.com/uglide/RedisDesktopManager</a></li>
                  </ul>
                  <h2 id="2-Windows下的安装"><a href="#2-Windows下的安装" class="headerlink" title="2. Windows下的安装"></a>2. Windows下的安装</h2>
                  <p>在Windows下，Redis可以直接到GitHub的发行版本里面下载，具体下载地址是<a href="https://github.com/MSOpenTech/redis/releases" target="_blank" rel="noopener">https://github.com/MSOpenTech/redis/releases</a>。</p>
                  <p>打开下载页面后，会发现有许多发行版本及其安装包，如图1-39所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-39.jpg" alt="">图1-39 下载页面</p>
                  <p>可以下载Redis-x64-3.2.100.msi安装即可。</p>
                  <p>安装过程比较简单，直接点击Next按钮安装即可。安装完成后，Redis便会启动。</p>
                  <p>在系统服务页面里，可以观察到多了一个正在运行到Redis服务，如图1-40所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-40.jpg" alt="">图1-40 系统服务页面</p>
                  <p>另外，推荐下载Redis Desktop Manager可视化管理工具，来管理Redis。这既可以到官方网站（链接为：<a href="https://redisdesktop.com/download" target="_blank" rel="noopener">https://redisdesktop.com/download</a>）下载，也可以到GitHub（链接为：<a href="https://github.com/uglide/RedisDesktopManager/releases" target="_blank" rel="noopener">https://github.com/uglide/RedisDesktopManager/releases</a>）下载最新发行版本。</p>
                  <p>安装后，直接连接本地Redis即可。</p>
                  <h2 id="3-Linux下的安装"><a href="#3-Linux下的安装" class="headerlink" title="3. Linux下的安装"></a>3. Linux下的安装</h2>
                  <p>这里依然分为两类平台来介绍。</p>
                  <h3 id="Ubuntu、Debian和Deepin"><a href="#Ubuntu、Debian和Deepin" class="headerlink" title="Ubuntu、Debian和Deepin"></a>Ubuntu、Debian和Deepin</h3>
                  <p>在Ubuntu、Debian和Deepin系统下，使用<code>apt-get</code>命令安装Redis：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="keyword">get</span> -y install redis-<span class="keyword">server</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后输入<code>redis-cli</code>进入Redis命令行模式：</p>
                  <figure class="highlight accesslog">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">$ redis-cli</span><br><span class="line"><span class="number">127.0.0.1:6379</span>&gt; set 'name' 'Germey'</span><br><span class="line">OK</span><br><span class="line"><span class="number">127.0.0.1:6379</span>&gt; get 'name'</span><br><span class="line"><span class="string">"Germey"</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样就证明Redis成功安装了，但是现在Redis还是无法远程连接的，依然需要修改配置文件，配置文件的路径为/etc/redis/redis.conf。</p>
                  <p>首先，注释这一行：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">bind <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>另外，推荐给Redis设置密码，取消注释这一行：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">requirepass foobared</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p><code>foobared</code>即当前密码，可以自行修改。</p>
                  <p>然后重启Redis服务，使用的命令如下：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo /etc/init.d/redis-<span class="keyword">server</span> <span class="keyword">restart</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>现在就可以使用密码远程连接Redis了。</p>
                  <p>另外，停止和启动Redis服务的命令分别如下：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo /etc/init.d/redis-<span class="keyword">server</span> stop</span><br><span class="line">sudo /etc/init.d/redis-<span class="keyword">server</span> <span class="keyword">start</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="CentOS和Red-Hat"><a href="#CentOS和Red-Hat" class="headerlink" title="CentOS和Red Hat"></a>CentOS和Red Hat</h3>
                  <p>在CentOS和Red Hat系统中，首先添加EPEL仓库，然后更新yum源：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum <span class="keyword">install</span> epel-<span class="keyword">release</span></span><br><span class="line">sudo yum <span class="keyword">update</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后安装Redis数据库：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum -y <span class="keyword">install</span> redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>安装好后启动Redis服务即可：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这里同样可以使用<code>redis-cli</code>进入Redis命令行模式操作。</p>
                  <p>另外，为了可以使Redis能被远程连接，需要修改配置文件，路径为/etc/redis.conf。</p>
                  <p>参见上文来修改配置文件实现远程连接和密码配置。</p>
                  <p>修改完成之后保存。</p>
                  <p>然后重启Redis服务即可，命令如下：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">sudo systemctl restart redis</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="4-Mac下的安装"><a href="#4-Mac下的安装" class="headerlink" title="4. Mac下的安装"></a>4. Mac下的安装</h2>
                  <p>这里推荐使用Homebrew安装，直接执行如下命令即可：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>启动Redis服务的命令如下：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">brew services <span class="keyword">start</span> redis</span><br><span class="line">redis-<span class="keyword">server</span> /usr/<span class="keyword">local</span>/etc/redis.conf</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这里同样可以使用<code>redis-cli</code>进入Redis命令行模式。</p>
                  <p>在Mac下Redis的配置文件路径是/usr/local/etc/redis.conf，可以通过修改它来配置访问密码。</p>
                  <p>修改配置文件后，需要重启Redis服务。停止和重启Redis服务的命令分别如下：</p>
                  <figure class="highlight armasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span>services stop redis</span><br><span class="line"><span class="keyword">brew </span>services restart redis</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>另外，在Mac下也可以安装Redis Desktop Manager可视化管理工具来管理Redis。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:24:32" itemprop="dateCreated datePublished" datetime="2018-01-25T15:24:32+08:00">2018-01-25</time>
                </span>
                <span id="/5219.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.4.3-Redis的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>2k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5205.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5205.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.4.2-MongoDB安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <h2 id="更新-2020-3-8"><a href="#更新-2020-3-8" class="headerlink" title="更新 2020/3/8"></a>更新 2020/3/8</h2>
                  <p>MongoDB 现在已经出到了 4.x 版本，下面的安装教程是基于 3.x 版本，可能已经过期。</p>
                  <p>关于 4.x 的安装教程，可以参考如下内容：</p>
                  <ul>
                    <li><a href="https://juejin.im/post/5d525b1af265da03b31bc2d5" target="_blank" rel="noopener">https://juejin.im/post/5d525b1af265da03b31bc2d5</a></li>
                    <li><a href="https://www.cnblogs.com/TM0831/p/10606624.html" target="_blank" rel="noopener">https://www.cnblogs.com/TM0831/p/10606624.html</a></li>
                    <li><a href="https://www.cnblogs.com/georgeleoo/p/11479409.html" target="_blank" rel="noopener">https://www.cnblogs.com/georgeleoo/p/11479409.html</a></li>
                  </ul>
                  <hr>
                  <p>以下为原文：</p>
                  <p>MongoDB是由C++语言编写的非关系型数据库，是一个基于分布式文件存储的开源数据库系统，其内容存储形式类似JSON对象，它的字段值可以包含其他文档、数组及文档数组，非常灵活。</p>
                  <p>MongoDB支持多种平台，包括Windows、Linux、Mac OS、Solaris等，在其官方网站（<a href="https://www.mongodb.com/download-center" target="_blank" rel="noopener">https://www.mongodb.com/download-center</a>）均可找到对应的安装包。</p>
                  <p>本节中，我们来看下它的安装过程。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.mongodb.com/" target="_blank" rel="noopener">https://www.mongodb.com</a></li>
                    <li>官方文档：<a href="https://docs.mongodb.com/" target="_blank" rel="noopener">https://docs.mongodb.com</a></li>
                    <li>GitHub：<a href="https://github.com/mongodb" target="_blank" rel="noopener">https://github.com/mongodb</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/mongodb/mongodb-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/mongodb/mongodb-tutorial.html</a></li>
                  </ul>
                  <h2 id="2-Windows下的安装"><a href="#2-Windows下的安装" class="headerlink" title="2. Windows下的安装"></a>2. Windows下的安装</h2>
                  <p>这里直接在官网（如图1-29所示）点击DOWNLOAD按钮下载msi安装包即可。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-29.jpg" alt="">图1-29 MongoDB官网</p>
                  <p>下载完成后，双击它开始安装，指定MongoDB的安装路径，例如此处我指定的安装路径为C:\MongoDB\Server\3.4，如图1-30所示。当然，这里也可以自行选择路径。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-30.jpg" alt="">图1-30 指定安装路径</p>
                  <p>点击Next按钮执行安装即可。</p>
                  <p>安装成功之后，进入MongoDB的安装目录，此处是C:\MongoDB\Server\3.4，在bin目录下新建同级目录data，如图1-31所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-31.jpg" alt="">图1-31 新建data目录</p>
                  <p>然后进入data文件夹，新建子文件夹db来存储数据目录，如图1-32所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-32.jpg" alt="">图1-32 新建db目录</p>
                  <p>之后打开命令行，进入MongoDB安装目录的bin目录下，运行MongoDB服务：</p>
                  <figure class="highlight taggerscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">mongod --dbpath "C:<span class="symbol">\M</span>ongoDB<span class="symbol">\S</span>erver<span class="symbol">\3</span>.4<span class="symbol">\d</span>ata<span class="symbol">\d</span>b"</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>请记得将此处的路径替换成你的主机MongoDB安装路径。</p>
                  <p>运行之后，会出现一些输出信息，如图1-33所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-33.jpg" alt="">图1-33 运行结果</p>
                  <p>这样我们就启动MongoDB服务了。</p>
                  <p>但是如果我们想一直使用MongoDB，就不能关闭此命令行了。如果意外关闭或重启，MongoDB服务就不能使用了。这显然不是我们想要的。所以，接下来还需将MongoDB配置成系统服务。</p>
                  <p>首先，以管理员模式运行命令行。注意，此处一定要以管理员身份运行，否则可能配置失败，如图1-34所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-34.jpg" alt="">图1-34 以管理员身份运行</p>
                  <p>在“开始”菜单中搜索cmd，找到命令行，然后右击它以管理员身份运行即可。</p>
                  <p>随后新建一个日志文件，在bin目录新建logs同级目录，进入之后新建一个mongodb.log文件，用于保存MongoDB的运行日志，如图1-35所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-35.jpg" alt="">图1-35 新建mongodb.log文件</p>
                  <p>在命令行下输入如下内容：</p>
                  <figure class="highlight jboss-cli">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">mongod <span class="params">--bind_ip</span> 0.0.0.0 <span class="params">--logpath</span> <span class="string">"C:\MongoDB\Server\3.4\logs\mongodb.log"</span> <span class="params">--logappend</span> <span class="params">--dbpath</span> <span class="string">"C:\MongoDB\Server\3.4\data\db"</span> <span class="params">--port</span> 27017 <span class="params">--serviceName</span> <span class="string">"MongoDB"</span> <span class="params">--serviceDisplayName</span> <span class="string">"MongoDB"</span> <span class="params">--install</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这里的意思是绑定IP为0.0.0.0（即任意IP均可访问），指定日志路径、数据库路径和端口，指定服务名称。需要注意的是，这里依然需要把路径替换成你的MongoDB安装路径，运行此命令后即可安装服务，运行结果如图1-36所示。<img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-36.jpg" alt="">图1-36 运行结果</p>
                  <p>如果没有出现错误提示，则证明MongoDB服务已经安装成功。</p>
                  <p>可以在服务管理页面查看到系统服务，如图1-37所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-37.jpg" alt="">图1-37 系统服务页面</p>
                  <p>然后就可以设置它的开机启动方式了，如自动启动或手动启动等，这样我们就可以非常方便地管理MongoDB服务了。</p>
                  <p>启动服务后，在命令行下就可以利用<code>mongo</code>命令进入MongoDB命令交互环境了，如图1-38所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-38.jpg" alt="">图1-38 命令行模式</p>
                  <p>这样，Windows下的MongoDB配置就完成了。</p>
                  <h2 id="3-Linux下的安装"><a href="#3-Linux下的安装" class="headerlink" title="3. Linux下的安装"></a>3. Linux下的安装</h2>
                  <p>这里以MongoDB 3.4为例说明MongoDB的安装过程。</p>
                  <h3 id="Ubuntu"><a href="#Ubuntu" class="headerlink" title="Ubuntu"></a>Ubuntu</h3>
                  <p>首先，导入MongoDB的GPG key：</p>
                  <figure class="highlight jboss-cli">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-key adv <span class="params">--keyserver</span> hkp:<span class="string">//keyserver.ubuntu.com</span><span class="function">:80</span> <span class="params">--recv</span> 0C49F3730359A14518585931BC711F9BA15703C6</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>随后创建apt-get源列表，各个系统版本对应的命令分别如下。</p>
                  <ul>
                    <li>
                      <p>Ubuntu 12.04对应的命令如下：</p>
                      <figure class="highlight lsl">
                        <table>
                          <tr>
                            <td class="gutter">
                              <pre><span class="line">1</span><br></pre>
                            </td>
                            <td class="code">
                              <pre><span class="line">echo <span class="string">"deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.4 multiverse"</span> | sudo tee /etc/apt/sources.<span class="type">list</span>.d/mongodb-org<span class="number">-3.4</span>.<span class="type">list</span></span><br></pre>
                            </td>
                          </tr>
                        </table>
                      </figure>
                    </li>
                    <li>
                      <p>Ubuntu 14.04对应的命令如下：</p>
                      <figure class="highlight lsl">
                        <table>
                          <tr>
                            <td class="gutter">
                              <pre><span class="line">1</span><br></pre>
                            </td>
                            <td class="code">
                              <pre><span class="line">echo <span class="string">"deb [ arch=amd64 ] http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse"</span> | sudo tee /etc/apt/sources.<span class="type">list</span>.d/mongodb-org<span class="number">-3.4</span>.<span class="type">list</span></span><br></pre>
                            </td>
                          </tr>
                        </table>
                      </figure>
                    </li>
                    <li>
                      <p>Ubuntu 16.04对应的命令如下：</p>
                      <figure class="highlight lsl">
                        <table>
                          <tr>
                            <td class="gutter">
                              <pre><span class="line">1</span><br></pre>
                            </td>
                            <td class="code">
                              <pre><span class="line">echo <span class="string">"deb [ arch=amd64,arm64 ] http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.4 multiverse"</span> | sudo tee /etc/apt/sources.<span class="type">list</span>.d/mongodb-org<span class="number">-3.4</span>.<span class="type">list</span></span><br></pre>
                            </td>
                          </tr>
                        </table>
                      </figure>
                    </li>
                  </ul>
                  <p>随后更新apt-get源：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="keyword">get</span> <span class="keyword">update</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>之后安装MongoDB即可：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-<span class="builtin-name">get</span> install -y mongodb-org</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>安装完成后运行MongoDB，命令如下：</p>
                  <figure class="highlight jboss-cli">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">mongod <span class="params">--port</span> 27017 <span class="params">--dbpath</span> <span class="string">/data/db</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行命令之后，MongoDB就在27017端口上运行了，数据文件会保存在/data/db路径下。</p>
                  <p>一般情况下，我们在Linux上配置MongoDB都是为了远程连接使用的，所以这里还需要配置一下MongoDB的远程连接以及用户名和密码。</p>
                  <p>接着，进入MongoDB命令行：</p>
                  <figure class="highlight ada">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">mongo <span class="comment">--port 27017</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>现在我们就已经进入到MongoDB的命令行交互模式下了，在此模式下运行如下命令：</p>
                  <figure class="highlight groovy">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">&gt; use admin</span><br><span class="line">switched to db admin</span><br><span class="line">&gt; db.createUser(&#123;<span class="string">user:</span> <span class="string">'admin'</span>, <span class="string">pwd:</span> <span class="string">'admin123'</span>, <span class="string">roles:</span> [&#123;<span class="string">role:</span> <span class="string">'root'</span>, <span class="string">db:</span> <span class="string">'admin'</span>&#125;]&#125;)</span><br><span class="line">Successfully added <span class="string">user:</span> &#123;</span><br><span class="line">        <span class="string">"user"</span> : <span class="string">"admin"</span>,</span><br><span class="line">        <span class="string">"roles"</span> : [</span><br><span class="line">                &#123;</span><br><span class="line">                        <span class="string">"role"</span> : <span class="string">"root"</span>,</span><br><span class="line">                        <span class="string">"db"</span> : <span class="string">"admin"</span></span><br><span class="line">                &#125;</span><br><span class="line">        ]</span><br><span class="line">&#125;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样我们就创建了一个用户名为admin，密码为admin123的用户，赋予最高权限。</p>
                  <p>随后需要修改MongoDB的配置文件，此时执行如下命令：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo <span class="keyword">vi</span> /etc/mongod.<span class="keyword">conf</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后修改<code>net</code>部分为：</p>
                  <figure class="highlight yaml">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">net:</span></span><br><span class="line">  <span class="attr">port:</span> <span class="number">27017</span></span><br><span class="line">  <span class="attr">bindIp:</span> <span class="number">0.0</span><span class="number">.0</span><span class="number">.0</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样配置后，MongoDB可被远程访问。</p>
                  <p>另外，还需要添加如下的权限认证配置，此时直接添加如下内容到配置文件即可：</p>
                  <figure class="highlight dts">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="symbol">security:</span></span><br><span class="line"><span class="symbol">  authorization:</span> enabled</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>配置完成之后，我们需要重新启动MongoDB服务，命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo<span class="built_in"> service </span>mongod restart</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这样远程连接和权限认证就配置完成了。</p>
                  <h5 id="CentOS和Red-Hat"><a href="#CentOS和Red-Hat" class="headerlink" title="CentOS和Red Hat"></a>CentOS和Red Hat</h5>
                  <p>首先，添加MongoDB源：</p>
                  <figure class="highlight awk">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo vi <span class="regexp">/etc/yum</span>.repos.d<span class="regexp">/mongodb-org.repo</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>接着修改如下内容并保存：</p>
                  <figure class="highlight ini">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="section">[mongodb-org-3.4]</span></span><br><span class="line"><span class="attr">name</span>=MongoDB Repository</span><br><span class="line"><span class="attr">baseurl</span>=https://repo.mongodb.org/yum/redhat/<span class="variable">$releasever</span>/mongodb-org/<span class="number">3.4</span>/x<span class="number">86_64</span>/</span><br><span class="line"><span class="attr">gpgcheck</span>=<span class="number">1</span></span><br><span class="line"><span class="attr">enabled</span>=<span class="number">1</span></span><br><span class="line"><span class="attr">gpgkey</span>=https://www.mongodb.org/static/pgp/server-<span class="number">3.4</span>.asc</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后执行<code>yum</code>命令安装：</p>
                  <figure class="highlight cmake">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo yum <span class="keyword">install</span> mongodb-org</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>这里启动MongoDB服务的命令如下：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> mongod</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>停止和重新加载MongoDB服务的命令如下：</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">sudo</span> <span class="string">systemctl stop mongod</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">systemctl reload mongod</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>有关远程连接和认证配置，可以参考前面，方式是相同的。</p>
                  <p>更多Linux发行版的MongoDB安装方式可以参考官方文档：<a href="https://docs.mongodb.com/manual/administration/install-on-linux/" target="_blank" rel="noopener">https://docs.mongodb.com/manual/administration/install-on-linux/</a>。</p>
                  <h2 id="4-Mac下的安装"><a href="#4-Mac下的安装" class="headerlink" title="4. Mac下的安装"></a>4. Mac下的安装</h2>
                  <p>这里推荐使用Homebrew安装，直接执行<code>brew</code>命令即可：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>mongodb</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>然后创建一个新文件夹/data/db，用于存放MongoDB数据。</p>
                  <p>这里启动MongoDB服务的命令如下：</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">brew</span> <span class="string">services start mongodb</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">mongod</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>停止和重启MongoDB服务的命令分别是：</p>
                  <figure class="highlight armasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span>services stop mongodb</span><br><span class="line"><span class="keyword">brew </span>services restart mongodb</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h2 id="5-可视化工具"><a href="#5-可视化工具" class="headerlink" title="5. 可视化工具"></a>5. 可视化工具</h2>
                  <p>这里推荐一个可视化工具RoboMongo/Robo 3T，它使用简单，功能强大，官方网站为<a href="https://robomongo.org/" target="_blank" rel="noopener">https://robomongo.org/</a>，三大平台都支持，下载链接为<a href="https://robomongo.org/download" target="_blank" rel="noopener">https://robomongo.org/download</a>。</p>
                  <p>另外，还有一个简单易用的可视化工具——Studio 3T，它同样具有方便的图形化管理界面，官方网站为<a href="https://studio3t.com/" target="_blank" rel="noopener">https://studio3t.com</a>，同样支持三大平台，下载链接为<a href="https://studio3t.com/download/" target="_blank" rel="noopener">https://studio3t.com/download/</a>。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:10:03" itemprop="dateCreated datePublished" datetime="2018-01-25T15:10:03+08:00">2018-01-25</time>
                </span>
                <span id="/5205.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.4.2-MongoDB安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>4.4k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>4 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5200.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5200.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.4.1-MySQL的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>MySQL是一个轻量级的关系型数据库，本节中我们来了解下它的安装方式。</p>
                  <h2 id="1-相关链接"><a href="#1-相关链接" class="headerlink" title="1. 相关链接"></a>1. 相关链接</h2>
                  <ul>
                    <li>官方网站：<a href="https://www.mysql.com/cn" target="_blank" rel="noopener">https://www.mysql.com/cn</a></li>
                    <li>下载地址：<a href="https://www.mysql.com/cn/downloads" target="_blank" rel="noopener">https://www.mysql.com/cn/downloads</a></li>
                    <li>中文教程：<a href="http://www.runoob.com/mysql/mysql-tutorial.html" target="_blank" rel="noopener">http://www.runoob.com/mysql/mysql-tutorial.html</a></li>
                  </ul>
                  <h2 id="2-Windows下的安装"><a href="#2-Windows下的安装" class="headerlink" title="2. Windows下的安装"></a>2. Windows下的安装</h2>
                  <p>对于Windows来说，可以直接在百度软件中心搜索MySQL，下载其提供的MySQL安装包，速度还是比较快的。</p>
                  <p>当然，最安全稳妥的方式是直接到官网下载安装包进行安装，但是这样做有个缺点，那就是需要登录才可以下载，而且速度不快。</p>
                  <p>下载完成后，双击安装包即可安装，这里直接选择默认选项，点击Next按钮安装即可。这里需要记住图1-27所设置的密码。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-27.jpg" alt="">图1-27 设置密码页面</p>
                  <p>安装完成后，我们可以在“计算机”→“管理”→“服务”页面开启和关闭MySQL服务，如图1-28所示。</p>
                  <p><img src="https://qiniu.cuiqingcai.com/wp-content/uploads/2018/02/1-28.jpg" alt="">图1-28 系统服务页面</p>
                  <p>如果启动了MySQL服务，就可以使用它来存储数据了。</p>
                  <h2 id="3-Linux下的安装"><a href="#3-Linux下的安装" class="headerlink" title="3. Linux下的安装"></a>3. Linux下的安装</h2>
                  <p>下面我们仍然分平台来介绍。</p>
                  <h3 id="Ubuntu、Debian和Deepin"><a href="#Ubuntu、Debian和Deepin" class="headerlink" title="Ubuntu、Debian和Deepin"></a>Ubuntu、Debian和Deepin</h3>
                  <p>在Ubuntu、Debian和Deepin系统中，我们直接使用<code>apt-get</code>命令即可安装MySQL：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo apt-get <span class="keyword">update</span></span><br><span class="line">sudo apt-<span class="keyword">get</span> <span class="keyword">install</span> -y mysql-<span class="keyword">server</span> mysql-<span class="keyword">client</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>在安装过程中，会提示输入用户名和密码，输入后等待片刻即可完成安装。</p>
                  <p>启动、关闭和重启MySQL服务的命令如下：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo<span class="built_in"> service </span>mysql start</span><br><span class="line">sudo<span class="built_in"> service </span>mysql stop</span><br><span class="line">sudo<span class="built_in"> service </span>mysql restart</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <h3 id="CentOS和Red-Hat"><a href="#CentOS和Red-Hat" class="headerlink" title="CentOS和Red Hat"></a>CentOS和Red Hat</h3>
                  <p>这里以MySQL 5.6的Yum源为例来说明（如果需要更高版本，可以另寻），安装命令如下：</p>
                  <figure class="highlight sql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">wget http://repo.mysql.com/mysql-community-<span class="keyword">release</span>-el7<span class="number">-5.</span>noarch.rpm</span><br><span class="line">sudo rpm -ivh mysql-community-<span class="keyword">release</span>-el7<span class="number">-5.</span>noarch.rpm</span><br><span class="line">yum <span class="keyword">install</span> -y mysql mysql-<span class="keyword">server</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>运行如上命令即可完成安装，初始密码为空。接下来，需要启动MySQL服务。</p>
                  <p>启动MySQL服务的命令如下：</p>
                  <figure class="highlight crmsh">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo systemctl <span class="literal">start</span> mysqld</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>停止、重启MySQL服务的命令如下：</p>
                  <figure class="highlight properties">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attr">sudo</span> <span class="string">systemctl stop mysqld</span></span><br><span class="line"><span class="attr">sudo</span> <span class="string">systemctl restart mysqld</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>上面我们完成了Linux下MySQL的安装，之后可以修改密码，此时可以执行如下命令：</p>
                  <figure class="highlight ebnf">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="attribute">mysql -uroot -p</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>输入密码后，进入MySQL命令行模式，接着输入如下命令：</p>
                  <figure class="highlight routeros">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">use mysql;</span><br><span class="line">UPDATE<span class="built_in"> user </span><span class="builtin-name">SET</span> Password = PASSWORD(<span class="string">'newpass'</span>) WHERE<span class="built_in"> user </span>= <span class="string">'root'</span>;</span><br><span class="line">FLUSH PRIVILEGES;</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>其中<code>newpass</code>为修改的新的MySQL密码，请自行替换。</p>
                  <p>由于Linux一般会作为服务器使用，为了使MySQL可以被远程访问，我们需要修改MySQL的配置文件，配置文件的路径一般为/etc/mysql/my.cnf。</p>
                  <p>比如，使用<code>vi</code>进行修改的命令如下：</p>
                  <figure class="highlight vim">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">vi</span> /etc/mysql/my.<span class="keyword">cnf</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>取消此行的注释如下：</p>
                  <figure class="highlight angelscript">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">bind-address = <span class="number">127.0</span><span class="number">.0</span><span class="number">.1</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>此行限制了MySQL只能本地访问而不能远程访问，取消注释即可解除此限制。</p>
                  <p>修改完成后重启MySQL服务，此时MySQL就可以被远程访问了。</p>
                  <p>到此为止，在Linux下安装MySQL的过程就结束了。</p>
                  <h2 id="4-Mac下的安装"><a href="#4-Mac下的安装" class="headerlink" title="4. Mac下的安装"></a>4. Mac下的安装</h2>
                  <p>这里推荐使用Homebrew安装，直接执行<code>brew</code>命令即可：</p>
                  <figure class="highlight mipsasm">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line"><span class="keyword">brew </span><span class="keyword">install </span>mysql</span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>启动、停止和重启MySQL服务的命令如下：</p>
                  <figure class="highlight pgsql">
                    <table>
                      <tr>
                        <td class="gutter">
                          <pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre>
                        </td>
                        <td class="code">
                          <pre><span class="line">sudo mysql.<span class="keyword">server</span> <span class="keyword">start</span></span><br><span class="line">sudo mysql.<span class="keyword">server</span> stop</span><br><span class="line">sudo mysql.<span class="keyword">server</span> <span class="keyword">restart</span></span><br></pre>
                        </td>
                      </tr>
                    </table>
                  </figure>
                  <p>Mac一般不会作为服务器使用，如果想取消本地host绑定，那么需要修改my.cnf 文件，然后重启服务。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:05:00" itemprop="dateCreated datePublished" datetime="2018-01-25T15:05:00+08:00">2018-01-25</time>
                </span>
                <span id="/5200.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.4.1-MySQL的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>1.7k</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>2 分钟</span>
                </span>
              </div>
            </article>
            <article itemscope itemtype="http://schema.org/Article" class="post-block index" lang="zh-CN">
              <link itemprop="mainEntityOfPage" href="https://cuiqingcai.com/5197.html">
              <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
                <meta itemprop="image" content="/images/avatar.png">
                <meta itemprop="name" content="崔庆才">
                <meta itemprop="description" content="崔庆才的个人站点，记录生活的瞬间，分享学习的心得。">
              </span>
              <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
                <meta itemprop="name" content="静觅">
              </span>
              <header class="post-header">
                <h2 class="post-title" itemprop="name headline">
                  <a class="label"> Python <i class="label-arrow"></i>
                  </a>
                  <a href="/5197.html" class="post-title-link" itemprop="url">[Python3网络爬虫开发实战] 1.4-数据库的安装</a>
                </h2>
              </header>
              <div class="post-body" itemprop="articleBody">
                <div class="thumb">
                  <img itemprop="contentUrl" class="random">
                </div>
                <div class="excerpt">
                  <p>
                  <p>作为数据存储的重要部分，数据库同样是必不可少的，数据库可以分为关系型数据库和非关系型数据库。</p>
                  <p>关系型数据库如SQLite、MySQL、Oracle、SQL Server、DB2等，其数据库是以表的形式存储，非关系型数据库如MongoDB、Redis，它们的存储形式是键值对，存储形式更加灵活。</p>
                  <p>本书用到的数据库主要有关系型数据库MySQL及非关系型数据库MongoDB、Redis。</p>
                  <p>本节中，我们来了解一下它们的安装方式。</p>
                  </p>
                </div>
              </div>
              <div class="post-meta">
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-user"></i>
                  </span>
                  <span class="post-meta-item-text">作者</span>
                  <span><a href="/authors/崔庆才" class="author" itemprop="url" rel="index">崔庆才</a></span>
                </span>
                <span class="post-meta-item">
                  <span class="post-meta-item-icon">
                    <i class="far fa-calendar"></i>
                  </span>
                  <span class="post-meta-item-text">发表于</span>
                  <time title="创建时间：2018-01-25 15:02:35" itemprop="dateCreated datePublished" datetime="2018-01-25T15:02:35+08:00">2018-01-25</time>
                </span>
                <span id="/5197.html" class="post-meta-item leancloud_visitors" data-flag-title="[Python3网络爬虫开发实战] 1.4-数据库的安装" title="阅读次数">
                  <span class="post-meta-item-icon">
                    <i class="fa fa-eye"></i>
                  </span>
                  <span class="post-meta-item-text">阅读次数：</span>
                  <span class="leancloud-visitors-count"></span>
                </span>
                <span class="post-meta-item" title="本文字数">
                  <span class="post-meta-item-icon">
                    <i class="far fa-file-word"></i>
                  </span>
                  <span class="post-meta-item-text">本文字数：</span>
                  <span>207</span>
                </span>
                <span class="post-meta-item" title="阅读时长">
                  <span class="post-meta-item-icon">
                    <i class="far fa-clock"></i>
                  </span>
                  <span class="post-meta-item-text">阅读时长 &asymp;</span>
                  <span>1 分钟</span>
                </span>
              </div>
            </article>
            <script>
              document.querySelectorAll('.random').forEach(item => item.src = "https://picsum.photos/id/" + Math.floor(Math.random() * Math.floor(300)) + "/200/133")

            </script>
            <nav class="pagination">
              <a class="extend prev" rel="prev" href="/page/18/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/18/">18</a><span class="page-number current">19</span><a class="page-number" href="/page/20/">20</a><span class="space">&hellip;</span><a class="page-number" href="/page/31/">31</a><a class="extend next" rel="next" href="/page/20/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
            </nav>
          </div>
          <script>
            window.addEventListener('tabs:register', () =>
            {
              let
              {
                activeClass
              } = CONFIG.comments;
              if (CONFIG.comments.storage)
              {
                activeClass = localStorage.getItem('comments_active') || activeClass;
              }
              if (activeClass)
              {
                let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
                if (activeTab)
                {
                  activeTab.click();
                }
              }
            });
            if (CONFIG.comments.storage)
            {
              window.addEventListener('tabs:click', event =>
              {
                if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
                let commentClass = event.target.classList[1];
                localStorage.setItem('comments_active', commentClass);
              });
            }

          </script>
        </div>
        <div class="toggle sidebar-toggle">
          <span class="toggle-line toggle-line-first"></span>
          <span class="toggle-line toggle-line-middle"></span>
          <span class="toggle-line toggle-line-last"></span>
        </div>
        <aside class="sidebar">
          <div class="sidebar-inner">
            <ul class="sidebar-nav motion-element">
              <li class="sidebar-nav-toc"> 文章目录 </li>
              <li class="sidebar-nav-overview"> 站点概览 </li>
            </ul>
            <!--noindex-->
            <div class="post-toc-wrap sidebar-panel">
            </div>
            <!--/noindex-->
            <div class="site-overview-wrap sidebar-panel">
              <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
                <img class="site-author-image" itemprop="image" alt="崔庆才" src="/images/avatar.png">
                <p class="site-author-name" itemprop="name">崔庆才</p>
                <div class="site-description" itemprop="description">崔庆才的个人站点，记录生活的瞬间，分享学习的心得。</div>
              </div>
              <div class="site-state-wrap motion-element">
                <nav class="site-state">
                  <div class="site-state-item site-state-posts">
                    <a href="/archives/">
                      <span class="site-state-item-count">608</span>
                      <span class="site-state-item-name">日志</span>
                    </a>
                  </div>
                  <div class="site-state-item site-state-categories">
                    <a href="/categories/">
                      <span class="site-state-item-count">24</span>
                      <span class="site-state-item-name">分类</span></a>
                  </div>
                  <div class="site-state-item site-state-tags">
                    <a href="/tags/">
                      <span class="site-state-item-count">156</span>
                      <span class="site-state-item-name">标签</span></a>
                  </div>
                </nav>
              </div>
              <div class="links-of-author motion-element">
                <span class="links-of-author-item">
                  <a href="https://github.com/Germey" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Germey" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
                </span>
                <span class="links-of-author-item">
                  <a href="mailto:cqc@cuiqingcai.com.com" title="邮件 → mailto:cqc@cuiqingcai.com.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>邮件</a>
                </span>
                <span class="links-of-author-item">
                  <a href="https://weibo.com/cuiqingcai" title="微博 → https:&#x2F;&#x2F;weibo.com&#x2F;cuiqingcai" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>微博</a>
                </span>
                <span class="links-of-author-item">
                  <a href="https://www.zhihu.com/people/Germey" title="知乎 → https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;Germey" rel="noopener" target="_blank"><i class="fa fa-magic fa-fw"></i>知乎</a>
                </span>
              </div>
            </div>
            <div style=" width: 100%;" class="sidebar-panel sidebar-panel-image sidebar-panel-active">
              <a href="https://tutorial.lengyue.video/?coupon=12ef4b1a-a3db-11ea-bb37-0242ac130002_cqx_850" target="_blank" rel="noopener">
                <img src="https://qiniu.cuiqingcai.com/bco2a.png" style=" width: 100%;">
              </a>
            </div>
            <div style=" width: 100%;" class="sidebar-panel sidebar-panel-image sidebar-panel-active">
              <a href="http://www.ipidea.net/?utm-source=cqc&utm-keyword=?cqc" target="_blank" rel="noopener">
                <img src="https://qiniu.cuiqingcai.com/0ywun.png" style=" width: 100%;">
              </a>
            </div>
            <div class="sidebar-panel sidebar-panel-tags sidebar-panel-active">
              <h4 class="name"> 标签云 </h4>
              <div class="content">
                <a href="/tags/2048/" style="font-size: 10px;">2048</a> <a href="/tags/API/" style="font-size: 10px;">API</a> <a href="/tags/Bootstrap/" style="font-size: 11.25px;">Bootstrap</a> <a href="/tags/CDN/" style="font-size: 10px;">CDN</a> <a href="/tags/CQC/" style="font-size: 10px;">CQC</a> <a href="/tags/CSS/" style="font-size: 10px;">CSS</a> <a href="/tags/CSS-%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 10px;">CSS 反爬虫</a> <a href="/tags/CV/" style="font-size: 10px;">CV</a> <a href="/tags/Django/" style="font-size: 10px;">Django</a> <a href="/tags/Eclipse/" style="font-size: 11.25px;">Eclipse</a> <a href="/tags/FTP/" style="font-size: 10px;">FTP</a> <a href="/tags/Git/" style="font-size: 10px;">Git</a> <a href="/tags/GitHub/" style="font-size: 13.75px;">GitHub</a> <a href="/tags/HTML5/" style="font-size: 10px;">HTML5</a> <a href="/tags/Hexo/" style="font-size: 10px;">Hexo</a> <a href="/tags/IT/" style="font-size: 10px;">IT</a> <a href="/tags/JSP/" style="font-size: 10px;">JSP</a> <a href="/tags/JavaScript/" style="font-size: 10px;">JavaScript</a> <a href="/tags/K8s/" style="font-size: 10px;">K8s</a> <a href="/tags/LOGO/" style="font-size: 10px;">LOGO</a> <a href="/tags/Linux/" style="font-size: 10px;">Linux</a> <a href="/tags/MIUI/" style="font-size: 10px;">MIUI</a> <a href="/tags/MongoDB/" style="font-size: 10px;">MongoDB</a> <a href="/tags/Mysql/" style="font-size: 10px;">Mysql</a> <a href="/tags/NBA/" style="font-size: 10px;">NBA</a> <a href="/tags/PHP/" style="font-size: 11.25px;">PHP</a> <a href="/tags/PS/" style="font-size: 10px;">PS</a> <a href="/tags/Pathlib/" style="font-size: 10px;">Pathlib</a> <a href="/tags/PhantomJS/" style="font-size: 10px;">PhantomJS</a> <a href="/tags/Python/" style="font-size: 15px;">Python</a> <a href="/tags/Python3/" style="font-size: 12.5px;">Python3</a> <a href="/tags/Pythonic/" style="font-size: 10px;">Pythonic</a> <a href="/tags/QQ/" style="font-size: 10px;">QQ</a> <a href="/tags/Redis/" style="font-size: 10px;">Redis</a> <a href="/tags/SAE/" style="font-size: 10px;">SAE</a> <a href="/tags/SSH/" style="font-size: 10px;">SSH</a> <a href="/tags/SVG/" style="font-size: 10px;">SVG</a> <a href="/tags/Scrapy/" style="font-size: 10px;">Scrapy</a> <a href="/tags/Scrapy-redis/" style="font-size: 10px;">Scrapy-redis</a> <a href="/tags/Scrapy%E5%88%86%E5%B8%83%E5%BC%8F/" style="font-size: 10px;">Scrapy分布式</a> <a href="/tags/Selenium/" style="font-size: 10px;">Selenium</a> <a href="/tags/TKE/" style="font-size: 10px;">TKE</a> <a href="/tags/Ubuntu/" style="font-size: 11.25px;">Ubuntu</a> <a href="/tags/VS-Code/" style="font-size: 10px;">VS Code</a> <a href="/tags/Vs-Code/" style="font-size: 10px;">Vs Code</a> <a href="/tags/Vue/" style="font-size: 11.25px;">Vue</a> <a href="/tags/Webpack/" style="font-size: 10px;">Webpack</a> <a href="/tags/Windows/" style="font-size: 10px;">Windows</a> <a href="/tags/Winpcap/" style="font-size: 10px;">Winpcap</a> <a href="/tags/WordPress/" style="font-size: 13.75px;">WordPress</a> <a href="/tags/Youtube/" style="font-size: 11.25px;">Youtube</a> <a href="/tags/android/" style="font-size: 10px;">android</a> <a href="/tags/ansible/" style="font-size: 10px;">ansible</a> <a href="/tags/cocos2d-x/" style="font-size: 10px;">cocos2d-x</a> <a href="/tags/e6/" style="font-size: 10px;">e6</a> <a href="/tags/fitvids/" style="font-size: 10px;">fitvids</a> <a href="/tags/git/" style="font-size: 11.25px;">git</a> <a href="/tags/json/" style="font-size: 10px;">json</a> <a href="/tags/js%E9%80%86%E5%90%91/" style="font-size: 10px;">js逆向</a> <a href="/tags/kubernetes/" style="font-size: 10px;">kubernetes</a> <a href="/tags/log/" style="font-size: 10px;">log</a> <a href="/tags/logging/" style="font-size: 10px;">logging</a> <a href="/tags/matlab/" style="font-size: 11.25px;">matlab</a> <a href="/tags/python/" style="font-size: 20px;">python</a> <a href="/tags/pytube/" style="font-size: 11.25px;">pytube</a> <a href="/tags/pywin32/" style="font-size: 10px;">pywin32</a> <a href="/tags/style/" style="font-size: 10px;">style</a> <a href="/tags/tomcat/" style="font-size: 10px;">tomcat</a> <a href="/tags/ubuntu/" style="font-size: 10px;">ubuntu</a> <a href="/tags/uwsgi/" style="font-size: 10px;">uwsgi</a> <a href="/tags/vsftpd/" style="font-size: 10px;">vsftpd</a> <a href="/tags/wamp/" style="font-size: 10px;">wamp</a> <a href="/tags/wineQQ/" style="font-size: 10px;">wineQQ</a> <a href="/tags/%E4%B8%83%E7%89%9B/" style="font-size: 11.25px;">七牛</a> <a href="/tags/%E4%B8%8A%E6%B5%B7/" style="font-size: 10px;">上海</a> <a href="/tags/%E4%B8%AA%E4%BA%BA%E7%BD%91%E7%AB%99/" style="font-size: 10px;">个人网站</a> <a href="/tags/%E4%B8%BB%E9%A2%98/" style="font-size: 10px;">主题</a> <a href="/tags/%E4%BA%91%E4%BA%A7%E5%93%81/" style="font-size: 10px;">云产品</a> <a href="/tags/%E4%BA%91%E5%AD%98%E5%82%A8/" style="font-size: 10px;">云存储</a> <a href="/tags/%E4%BA%AC%E4%B8%9C%E4%BA%91/" style="font-size: 10px;">京东云</a> <a href="/tags/%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD/" style="font-size: 12.5px;">人工智能</a> <a href="/tags/%E4%BB%A3%E7%90%86/" style="font-size: 10px;">代理</a> <a href="/tags/%E4%BB%A3%E7%A0%81/" style="font-size: 10px;">代码</a> <a href="/tags/%E4%BB%A3%E7%A0%81%E5%88%86%E4%BA%AB%E5%9B%BE/" style="font-size: 10px;">代码分享图</a> <a href="/tags/%E4%BC%98%E5%8C%96/" style="font-size: 10px;">优化</a> <a href="/tags/%E4%BD%8D%E8%BF%90%E7%AE%97/" style="font-size: 10px;">位运算</a> <a href="/tags/%E5%85%AC%E4%BC%97%E5%8F%B7/" style="font-size: 10px;">公众号</a> <a href="/tags/%E5%88%86%E4%BA%AB/" style="font-size: 10px;">分享</a> <a href="/tags/%E5%88%86%E5%B8%83%E5%BC%8F/" style="font-size: 10px;">分布式</a> <a href="/tags/%E5%88%9B%E4%B8%9A/" style="font-size: 10px;">创业</a> <a href="/tags/%E5%89%8D%E7%AB%AF/" style="font-size: 12.5px;">前端</a> <a href="/tags/%E5%8D%9A%E5%AE%A2/" style="font-size: 10px;">博客</a> <a href="/tags/%E5%8E%9F%E7%94%9FAPP/" style="font-size: 10px;">原生APP</a> <a href="/tags/%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 12.5px;">反爬虫</a> <a href="/tags/%E5%91%BD%E4%BB%A4/" style="font-size: 10px;">命令</a> <a href="/tags/%E5%93%8D%E5%BA%94%E5%BC%8F%E5%B8%83%E5%B1%80/" style="font-size: 10px;">响应式布局</a> <a href="/tags/%E5%9E%83%E5%9C%BE%E9%82%AE%E4%BB%B6/" style="font-size: 10px;">垃圾邮件</a> <a href="/tags/%E5%9F%9F%E5%90%8D%E7%BB%91%E5%AE%9A/" style="font-size: 10px;">域名绑定</a> <a href="/tags/%E5%A4%8D%E7%9B%98/" style="font-size: 10px;">复盘</a> <a href="/tags/%E5%A4%A7%E4%BC%97%E7%82%B9%E8%AF%84/" style="font-size: 10px;">大众点评</a> <a href="/tags/%E5%AD%97%E4%BD%93%E5%8F%8D%E7%88%AC%E8%99%AB/" style="font-size: 10px;">字体反爬虫</a> <a href="/tags/%E5%AD%97%E7%AC%A6%E9%97%AE%E9%A2%98/" style="font-size: 10px;">字符问题</a> <a href="/tags/%E5%AD%A6%E4%B9%A0%E6%96%B9%E6%B3%95/" style="font-size: 10px;">学习方法</a> <a href="/tags/%E5%AE%89%E5%8D%93/" style="font-size: 10px;">安卓</a> <a href="/tags/%E5%AE%9E%E7%94%A8/" style="font-size: 10px;">实用</a> <a href="/tags/%E5%B0%81%E9%9D%A2/" style="font-size: 10px;">封面</a> <a href="/tags/%E5%B4%94%E5%BA%86%E6%89%8D/" style="font-size: 18.75px;">崔庆才</a> <a href="/tags/%E5%B7%A5%E5%85%B7/" style="font-size: 12.5px;">工具</a> <a href="/tags/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" style="font-size: 10px;">开发工具</a> <a href="/tags/%E5%BE%AE%E8%BD%AF/" style="font-size: 10px;">微软</a> <a href="/tags/%E6%80%9D%E8%80%83/" style="font-size: 10px;">思考</a> <a href="/tags/%E6%89%8B%E6%9C%BA%E8%AE%BF%E9%97%AE/" style="font-size: 10px;">手机访问</a> <a href="/tags/%E6%95%99%E7%A8%8B/" style="font-size: 10px;">教程</a> <a href="/tags/%E6%95%99%E8%82%B2/" style="font-size: 10px;">教育</a> <a href="/tags/%E6%96%B0%E4%B9%A6/" style="font-size: 12.5px;">新书</a> <a href="/tags/%E6%96%B9%E6%B3%95%E8%AE%BA/" style="font-size: 10px;">方法论</a> <a href="/tags/%E6%97%85%E6%B8%B8/" style="font-size: 10px;">旅游</a> <a href="/tags/%E6%97%A5%E5%BF%97/" style="font-size: 10px;">日志</a> <a href="/tags/%E6%9A%97%E6%97%B6%E9%97%B4/" style="font-size: 10px;">暗时间</a> <a href="/tags/%E6%9D%9C%E5%85%B0%E7%89%B9/" style="font-size: 11.25px;">杜兰特</a> <a href="/tags/%E6%A1%8C%E9%9D%A2/" style="font-size: 10px;">桌面</a> <a href="/tags/%E6%AD%8C%E5%8D%95/" style="font-size: 10px;">歌单</a> <a href="/tags/%E6%B1%9F%E5%8D%97/" style="font-size: 10px;">江南</a> <a href="/tags/%E6%B8%B8%E6%88%8F/" style="font-size: 10px;">游戏</a> <a href="/tags/%E7%84%A6%E8%99%91/" style="font-size: 10px;">焦虑</a> <a href="/tags/%E7%88%AC%E8%99%AB/" style="font-size: 16.25px;">爬虫</a> <a href="/tags/%E7%88%AC%E8%99%AB%E4%B9%A6%E7%B1%8D/" style="font-size: 11.25px;">爬虫书籍</a> <a href="/tags/%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F/" style="font-size: 10px;">环境变量</a> <a href="/tags/%E7%94%9F%E6%B4%BB%E7%AC%94%E8%AE%B0/" style="font-size: 10px;">生活笔记</a> <a href="/tags/%E7%99%BB%E5%BD%95/" style="font-size: 10px;">登录</a> <a href="/tags/%E7%9F%A5%E4%B9%8E/" style="font-size: 10px;">知乎</a> <a href="/tags/%E7%9F%AD%E4%BF%A1/" style="font-size: 10px;">短信</a> <a href="/tags/%E7%9F%AD%E4%BF%A1%E9%AA%8C%E8%AF%81%E7%A0%81/" style="font-size: 10px;">短信验证码</a> <a href="/tags/%E7%AC%94%E8%AE%B0%E8%BD%AF%E4%BB%B6/" style="font-size: 10px;">笔记软件</a> <a href="/tags/%E7%AF%AE%E7%BD%91/" style="font-size: 10px;">篮网</a> <a href="/tags/%E7%BA%B8%E5%BC%A0/" style="font-size: 10px;">纸张</a> <a href="/tags/%E7%BB%84%E4%BB%B6/" style="font-size: 10px;">组件</a> <a href="/tags/%E7%BD%91%E7%AB%99/" style="font-size: 10px;">网站</a> <a href="/tags/%E7%BD%91%E7%BB%9C%E7%88%AC%E8%99%AB/" style="font-size: 11.25px;">网络爬虫</a> <a href="/tags/%E7%BE%8E%E5%AD%A6/" style="font-size: 10px;">美学</a> <a href="/tags/%E8%82%89%E5%A4%B9%E9%A6%8D/" style="font-size: 10px;">肉夹馍</a> <a href="/tags/%E8%85%BE%E8%AE%AF%E4%BA%91/" style="font-size: 10px;">腾讯云</a> <a href="/tags/%E8%87%AA%E5%BE%8B/" style="font-size: 10px;">自律</a> <a href="/tags/%E8%A5%BF%E5%B0%91%E7%88%B7/" style="font-size: 10px;">西少爷</a> <a href="/tags/%E8%A7%86%E9%A2%91/" style="font-size: 10px;">视频</a> <a href="/tags/%E8%B0%B7%E6%AD%8C%E9%AA%8C%E8%AF%81%E7%A0%81/" style="font-size: 10px;">谷歌验证码</a> <a href="/tags/%E8%BF%90%E8%90%A5/" style="font-size: 10px;">运营</a> <a href="/tags/%E8%BF%9C%E7%A8%8B/" style="font-size: 10px;">远程</a> <a href="/tags/%E9%80%86%E5%90%91/" style="font-size: 10px;">逆向</a> <a href="/tags/%E9%85%8D%E7%BD%AE/" style="font-size: 10px;">配置</a> <a href="/tags/%E9%87%8D%E8%A3%85/" style="font-size: 10px;">重装</a> <a href="/tags/%E9%98%BF%E6%9D%9C/" style="font-size: 10px;">阿杜</a> <a href="/tags/%E9%9D%99%E8%A7%85/" style="font-size: 17.5px;">静觅</a> <a href="/tags/%E9%A2%A0%E8%A6%86/" style="font-size: 10px;">颠覆</a> <a href="/tags/%E9%A3%9E%E4%BF%A1/" style="font-size: 10px;">飞信</a> <a href="/tags/%E9%B8%BF%E8%92%99/" style="font-size: 10px;">鸿蒙</a>
              </div>
              <script>
                const tagsColors = ['#00a67c', '#5cb85c', '#d9534f', '#567e95', '#b37333', '#f4843d', '#15a287']
                const tagsElements = document.querySelectorAll('.sidebar-panel-tags .content a')
                tagsElements.forEach((item) =>
                {
                  item.style.backgroundColor = tagsColors[Math.floor(Math.random() * tagsColors.length)]
                })

              </script>
            </div>
            <div class="sidebar-panel sidebar-panel-categories sidebar-panel-active">
              <h4 class="name"> 分类 </h4>
              <div class="content">
                <ul class="category-list">
                  <li class="category-list-item"><a class="category-list-link" href="/categories/C-C/">C/C++</a><span class="category-list-count">23</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/HTML/">HTML</a><span class="category-list-count">14</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Java/">Java</a><span class="category-list-count">5</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/JavaScript/">JavaScript</a><span class="category-list-count">26</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Linux/">Linux</a><span class="category-list-count">15</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Markdown/">Markdown</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Net/">Net</a><span class="category-list-count">4</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Other/">Other</a><span class="category-list-count">39</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/PHP/">PHP</a><span class="category-list-count">27</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Paper/">Paper</a><span class="category-list-count">2</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/Python/">Python</a><span class="category-list-count">261</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/TypeScript/">TypeScript</a><span class="category-list-count">2</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E5%B1%95%E7%A4%BA/">个人展示</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E6%97%A5%E8%AE%B0/">个人日记</a><span class="category-list-count">9</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E8%AE%B0%E5%BD%95/">个人记录</a><span class="category-list-count">4</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E4%B8%AA%E4%BA%BA%E9%9A%8F%E7%AC%94/">个人随笔</a><span class="category-list-count">15</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/">安装配置</a><span class="category-list-count">59</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E6%8A%80%E6%9C%AF%E6%9D%82%E8%B0%88/">技术杂谈</a><span class="category-list-count">88</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E6%9C%AA%E5%88%86%E7%B1%BB/">未分类</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E7%94%9F%E6%B4%BB%E7%AC%94%E8%AE%B0/">生活笔记</a><span class="category-list-count">1</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E7%A6%8F%E5%88%A9%E4%B8%93%E5%8C%BA/">福利专区</a><span class="category-list-count">6</span></li>
                  <li class="category-list-item"><a class="category-list-link" href="/categories/%E8%81%8C%E4%BD%8D%E6%8E%A8%E8%8D%90/">职位推荐</a><span class="category-list-count">2</span></li>
                </ul>
              </div>
            </div>
            <div class="sidebar-panel sidebar-panel-friends sidebar-panel-active">
              <h4 class="name"> 友情链接 </h4>
              <ul class="friends">
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/j2dub.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.findhao.net/" target="_blank" rel="noopener">FindHao</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ou6mm.jpg">
                  </span>
                  <span class="link">
                    <a href="https://diygod.me/" target="_blank" rel="noopener">DIYgod</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/6apxu.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.51dev.com/" target="_blank" rel="noopener">IT技术社区</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.jankl.com/img/titleshu.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.jankl.com/" target="_blank" rel="noopener">liberalist</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/bqlbs.png">
                  </span>
                  <span class="link">
                    <a href="http://www.urselect.com/" target="_blank" rel="noopener">优社电商</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/8s88c.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.yuanrenxue.com/" target="_blank" rel="noopener">猿人学</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/2wgg5.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.yunlifang.cn/" target="_blank" rel="noopener">云立方</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/shwr6.png">
                  </span>
                  <span class="link">
                    <a href="http://lanbing510.info/" target="_blank" rel="noopener">冰蓝</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/blvoh.jpg">
                  </span>
                  <span class="link">
                    <a href="https://lengyue.me/" target="_blank" rel="noopener">冷月</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="http://qianxunclub.com/favicon.png">
                  </span>
                  <span class="link">
                    <a href="http://qianxunclub.com/" target="_blank" rel="noopener">千寻啊千寻</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/0044u.jpg">
                  </span>
                  <span class="link">
                    <a href="http://kodcloud.com/" target="_blank" rel="noopener">可道云</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ygnpn.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.kunkundashen.cn/" target="_blank" rel="noopener">坤坤大神</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/22uv1.png">
                  </span>
                  <span class="link">
                    <a href="http://www.cenchong.com/" target="_blank" rel="noopener">岑冲博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ev9kl.png">
                  </span>
                  <span class="link">
                    <a href="http://www.zxiaoji.com/" target="_blank" rel="noopener">张小鸡</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.503error.com/favicon.ico">
                  </span>
                  <span class="link">
                    <a href="https://www.503error.com/" target="_blank" rel="noopener">张志明个人博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/x714o.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.hubwiz.com/" target="_blank" rel="noopener">汇智网</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/129d8.png">
                  </span>
                  <span class="link">
                    <a href="https://www.bysocket.com/" target="_blank" rel="noopener">泥瓦匠BYSocket</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://www.xiongge.club/favicon.ico">
                  </span>
                  <span class="link">
                    <a href="https://www.xiongge.club/" target="_blank" rel="noopener">熊哥club</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/3w4fe.png">
                  </span>
                  <span class="link">
                    <a href="https://zerlong.com/" target="_blank" rel="noopener">知语</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/44hxf.png">
                  </span>
                  <span class="link">
                    <a href="http://redstonewill.com/" target="_blank" rel="noopener">红色石头</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/8g1fk.jpg">
                  </span>
                  <span class="link">
                    <a href="http://www.laodong.me/" target="_blank" rel="noopener">老董博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/wkaus.jpg">
                  </span>
                  <span class="link">
                    <a href="https://zhaoshuai.me/" target="_blank" rel="noopener">碎念</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/pgo0r.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.chenwenguan.com/" target="_blank" rel="noopener">陈文管的博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/kk82a.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.lxlinux.net/" target="_blank" rel="noopener">良许Linux教程网</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/lj0t2.jpg">
                  </span>
                  <span class="link">
                    <a href="https://tanqingbo.cn/" target="_blank" rel="noopener">IT码农</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/i8cdr.png">
                  </span>
                  <span class="link">
                    <a href="https://junyiseo.com/" target="_blank" rel="noopener">均益个人博客</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/chwv2.png">
                  </span>
                  <span class="link">
                    <a href="https://brucedone.com/" target="_blank" rel="noopener">大鱼的鱼塘</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/2y43o.png">
                  </span>
                  <span class="link">
                    <a href="http://bbs.nightteam.cn/" target="_blank" rel="noopener">夜幕爬虫安全论坛</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/zvc3w.jpg">
                  </span>
                  <span class="link">
                    <a href="https://www.weishidong.com/" target="_blank" rel="noopener">韦世东的技术专栏</a>
                  </span>
                </li>
                <li class="friend">
                  <span class="logo">
                    <img src="https://qiniu.cuiqingcai.com/ebudy.jpg">
                  </span>
                  <span class="link">
                    <a href="https://chuanjiabing.com/" target="_blank" rel="noopener">穿甲兵技术社区</a>
                  </span>
                </li>
              </ul>
            </div>
          </div>
        </aside>
        <div id="sidebar-dimmer"></div>
      </div>
    </main>
    <footer class="footer">
      <div class="footer-inner">
        <div class="copyright"> &copy; <span itemprop="copyrightYear">2021</span>
          <span class="with-love">
            <i class="fa fa-heart"></i>
          </span>
          <span class="author" itemprop="copyrightHolder">崔庆才丨静觅</span>
          <span class="post-meta-divider">|</span>
          <span class="post-meta-item-icon">
            <i class="fa fa-chart-area"></i>
          </span>
          <span title="站点总字数">2.6m</span>
          <span class="post-meta-divider">|</span>
          <span class="post-meta-item-icon">
            <i class="fa fa-coffee"></i>
          </span>
          <span title="站点阅读时长">39:54</span>
        </div>
        <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> 强力驱动 </div>
        <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">京ICP备18015597号-1 </a>
        </div>
        <script>
          (function ()
          {
            function leancloudSelector(url)
            {
              url = encodeURI(url);
              return document.getElementById(url).querySelector('.leancloud-visitors-count');
            }

            function addCount(Counter)
            {
              var visitors = document.querySelector('.leancloud_visitors');
              var url = decodeURI(visitors.id);
              var title = visitors.dataset.flagTitle;
              Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify(
              {
                url
              }))).then(response => response.json()).then((
              {
                results
              }) =>
              {
                if (results.length > 0)
                {
                  var counter = results[0];
                  leancloudSelector(url).innerText = counter.time + 1;
                  Counter('put', '/classes/Counter/' + counter.objectId,
                  {
                    time:
                    {
                      '__op': 'Increment',
                      'amount': 1
                    }
                  }).catch(error =>
                  {
                    console.error('Failed to save visitor count', error);
                  });
                }
                else
                {
                  Counter('post', '/classes/Counter',
                  {
                    title,
                    url,
                    time: 1
                  }).then(response => response.json()).then(() =>
                  {
                    leancloudSelector(url).innerText = 1;
                  }).catch(error =>
                  {
                    console.error('Failed to create', error);
                  });
                }
              }).catch(error =>
              {
                console.error('LeanCloud Counter Error', error);
              });
            }

            function showTime(Counter)
            {
              var visitors = document.querySelectorAll('.leancloud_visitors');
              var entries = [...visitors].map(element =>
              {
                return decodeURI(element.id);
              });
              Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify(
              {
                url:
                {
                  '$in': entries
                }
              }))).then(response => response.json()).then((
              {
                results
              }) =>
              {
                for (let url of entries)
                {
                  let target = results.find(item => item.url === url);
                  leancloudSelector(url).innerText = target ? target.time : 0;
                }
              }).catch(error =>
              {
                console.error('LeanCloud Counter Error', error);
              });
            }
            let
            {
              app_id,
              app_key,
              server_url
            } = {
              "enable": true,
              "app_id": "6X5dRQ0pnPWJgYy8SXOg0uID-gzGzoHsz",
              "app_key": "ziLDVEy73ne5HtFTiGstzHMS",
              "server_url": "https://6x5drq0p.lc-cn-n1-shared.com",
              "security": false
            };

            function fetchData(api_server)
            {
              var Counter = (method, url, data) =>
              {
                return fetch(`${api_server}/1.1${url}`,
                {
                  method,
                  headers:
                  {
                    'X-LC-Id': app_id,
                    'X-LC-Key': app_key,
                    'Content-Type': 'application/json',
                  },
                  body: JSON.stringify(data)
                });
              };
              if (CONFIG.page.isPost)
              {
                if (CONFIG.hostname !== location.hostname) return;
                addCount(Counter);
              }
              else if (document.querySelectorAll('.post-title-link').length >= 1)
              {
                showTime(Counter);
              }
            }
            let api_server = app_id.slice(-9) !== '-MdYXbMMI' ? server_url : `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com`;
            if (api_server)
            {
              fetchData(api_server);
            }
            else
            {
              fetch('https://app-router.leancloud.cn/2/route?appId=' + app_id).then(response => response.json()).then((
              {
                api_server
              }) =>
              {
                fetchData('https://' + api_server);
              });
            }
          })();

        </script>
      </div>
      <div class="footer-stat">
        <span id="cnzz_stat_icon_1279355174"></span>
        <script type="text/javascript">
          document.write(unescape("%3Cspan id='cnzz_stat_icon_1279355174'%3E%3C/span%3E%3Cscript src='https://v1.cnzz.com/z_stat.php%3Fid%3D1279355174%26online%3D1%26show%3Dline' type='text/javascript'%3E%3C/script%3E"));

        </script>
      </div>
    </footer>
  </div>
  <script src="//cdn.jsdelivr.net/npm/animejs@3.2.1/lib/anime.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/pangu@4/dist/browser/pangu.min.js"></script>
  <script src="/js/utils.js"></script>
  <script src="/.js"></script>
  <script src="/js/schemes/pisces.js"></script>
  <script src="/.js"></script>
  <script src="/js/next-boot.js"></script>
  <script src="/.js"></script>
  <script>
    (function ()
    {
      var canonicalURL, curProtocol;
      //Get the <link> tag
      var x = document.getElementsByTagName("link");
      //Find the last canonical URL
      if (x.length > 0)
      {
        for (i = 0; i < x.length; i++)
        {
          if (x[i].rel.toLowerCase() == 'canonical' && x[i].href)
          {
            canonicalURL = x[i].href;
          }
        }
      }
      //Get protocol
      if (!canonicalURL)
      {
        curProtocol = window.location.protocol.split(':')[0];
      }
      else
      {
        curProtocol = canonicalURL.split(':')[0];
      }
      //Get current URL if the canonical URL does not exist
      if (!canonicalURL) canonicalURL = window.location.href;
      //Assign script content. Replace current URL with the canonical URL
      ! function ()
      {
        var e = /([http|https]:\/\/[a-zA-Z0-9\_\.]+\.baidu\.com)/gi,
          r = canonicalURL,
          t = document.referrer;
        if (!e.test(r))
        {
          var n = (String(curProtocol).toLowerCase() === 'https') ? "https://sp0.baidu.com/9_Q4simg2RQJ8t7jm9iCKT-xh_/s.gif" : "//api.share.baidu.com/s.gif";
          t ? (n += "?r=" + encodeURIComponent(document.referrer), r && (n += "&l=" + r)) : r && (n += "?l=" + r);
          var i = new Image;
          i.src = n
        }
      }(window);
    })();

  </script>
  <script src="/js/local-search.js"></script>
  <script src="/.js"></script>
</body>

</html>
